Mercurial > piecrust2
comparison piecrust/records.py @ 7:343d08ef5668
More PieCrust 3 fixes, and a couple of miscellaneous bug fixes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 16 Aug 2014 15:07:22 -0700 |
parents | 474c9882decf |
children | e88e330eb8dc |
comparison
equal
deleted
inserted
replaced
6:f5ca5c5bed85 | 7:343d08ef5668 |
---|---|
33 def save(self, path): | 33 def save(self, path): |
34 path_dir = os.path.dirname(path) | 34 path_dir = os.path.dirname(path) |
35 if not os.path.isdir(path_dir): | 35 if not os.path.isdir(path_dir): |
36 os.makedirs(path_dir, 0o755) | 36 os.makedirs(path_dir, 0o755) |
37 | 37 |
38 with open(path, 'w') as fp: | 38 with open(path, 'wb') as fp: |
39 pickle.dump(self, fp, pickle.HIGHEST_PROTOCOL) | 39 pickle.dump(self, fp, pickle.HIGHEST_PROTOCOL) |
40 | 40 |
41 def __getstate__(self): | 41 def __getstate__(self): |
42 odict = self.__dict__.copy() | 42 odict = self.__dict__.copy() |
43 del odict['entry_added'] | 43 del odict['entry_added'] |
44 return odict | 44 return odict |
45 | 45 |
46 @staticmethod | 46 @staticmethod |
47 def load(path): | 47 def load(path): |
48 logger.debug("Loading bake record from: %s" % path) | 48 logger.debug("Loading bake record from: %s" % path) |
49 with open(path, 'r') as fp: | 49 with open(path, 'rb') as fp: |
50 return pickle.load(fp) | 50 return pickle.load(fp) |
51 | 51 |