From 55c23697df6f08d25b576709e7532b72e7407a24 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 26 Oct 2012 14:07:49 -1000 Subject: [PATCH] Fixed: Incorrect call arguments Inspector assumed TagProperty was instance method Classmethod should have cls as first argument, not self. --- infiniteworld.py | 18 +++++++++--------- run_regression_test.py | 2 +- schematic.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/infiniteworld.py b/infiniteworld.py index 1a1d56b..6a66e86 100644 --- a/infiniteworld.py +++ b/infiniteworld.py @@ -1027,7 +1027,16 @@ class ChunkedLevelMixin(MCLevel): for ch in startingDirtyChunks: ch.needsLighting = False +def TagProperty(tagName, tagType, defaultValueFunc=lambda self: None): + def getter(self): + if tagName not in self.root_tag["Data"]: + self.root_tag["Data"][tagName] = tagType(defaultValueFunc(self)) + return self.root_tag["Data"][tagName].value + def setter(self, val): + self.root_tag["Data"][tagName] = tagType(value=val) + + return property(getter, setter) class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel): materials = alphaMaterials @@ -1082,16 +1091,7 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel): def __str__(self): return "MCInfdevOldLevel(\"" + os.path.split(self.worldDir)[1] + "\")" - def TagProperty(tagName, tagType, defaultValueFunc=lambda self: None): - def getter(self): - if tagName not in self.root_tag["Data"]: - self.root_tag["Data"][tagName] = tagType(defaultValueFunc(self)) - return self.root_tag["Data"][tagName].value - def setter(self, val): - self.root_tag["Data"][tagName] = tagType(value=val) - - return property(getter, setter) SizeOnDisk = TagProperty('SizeOnDisk', nbt.TAG_Long) RandomSeed = TagProperty('RandomSeed', nbt.TAG_Long) diff --git a/run_regression_test.py b/run_regression_test.py index 7da0d1c..0918d82 100755 --- a/run_regression_test.py +++ b/run_regression_test.py @@ -65,7 +65,7 @@ def directory_clone(src): @contextlib.contextmanager def unzipped_content(src): with temporary_directory() as dest: - f = zipfile.ZipFile.open(src) + f = zipfile.ZipFile(src) f.extractall(dest) yield dest diff --git a/schematic.py b/schematic.py index 8780ee9..60d64cc 100644 --- a/schematic.py +++ b/schematic.py @@ -299,7 +299,7 @@ class MCSchematic (EntityLevel): return self.Data[x, z, y] @classmethod - def chestWithItemID(self, itemID, count=64, damage=0): + def chestWithItemID(cls, itemID, count=64, damage=0): """ Creates a chest with a stack of 'itemID' in each slot. Optionally specify the count of items in each stack. Pass a negative value for damage to create unnaturally sturdy tools. """