Skip to content

Commit

Permalink
Merge pull request #2 from w3c/jgraham/sourcefile_pickle
Browse files Browse the repository at this point in the history
Fix pickling of SourceFile objects
  • Loading branch information
jgraham committed Apr 9, 2015
2 parents ca2677f + 933d204 commit 0282a0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions manifest/sourcefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def __init__(self, tests_root, rel_path, url_base, use_committed=False):

self.meta_flags = self.name.split(".")[1:]

def __getstate__(self):
# Remove computed properties if we pickle this class
rv = self.__dict__.copy()
for key in rv.keys():
if key in rv["__cached_properties__"]:
del rv[key]
del rv["__cached_properties__"]
return rv

def name_prefix(self, prefix):
"""Check if the filename starts with a given prefix
Expand Down
1 change: 1 addition & 0 deletions manifest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ def __get__(self, obj, cls=None):

if self.name not in obj.__dict__:
obj.__dict__[self.name] = self.func(obj)
obj.__dict__.setdefault("__cached_properties__", set()).add(self.name)
return obj.__dict__[self.name]

0 comments on commit 0282a0f

Please sign in to comment.