0

added __getstate__ and __setstate__ to TileSet to fix pickling

This commit is contained in:
Andrew Brown
2012-01-16 02:19:34 -05:00
parent 70ef0af00c
commit dafb659315
2 changed files with 13 additions and 1 deletions

View File

@@ -265,6 +265,13 @@ class TileSet(object):
else:
raise ValueError("imgformat must be one of: 'png' or 'jpeg'")
# Only pickle the initial state. Don't pickle anything resulting from the
# do_preprocessing step
def __getstate__(self):
return self.regionset, self.am, self.textures, self.options, self.outputdir
def __setstate__(self, state):
self.__init__(*state)
def do_preprocessing(self):
"""For the preprocessing step of the Worker interface, this does the
chunk scan and stores the resulting tree as a private instance
@@ -1262,6 +1269,12 @@ class RenderTile(object):
def __ne__(self, other):
return not self == other
# To support pickling
def __getstate__(self):
return self.col, self.row, self.path
def __setstate__(self, state):
self.__init__(*state)
def get_filepath(self, tiledir, imgformat):
"""Returns the path to this file given the directory to the tiles