From c3c44a60bf45a79a46a915fa135e8c7fdcab8d6b Mon Sep 17 00:00:00 2001 From: Caleb Deveraux Date: Mon, 27 Sep 2010 09:00:49 +0800 Subject: [PATCH 1/3] Use new-style classes so properties work Properties don't work on old-style classes. Convert classes to new-style by explicitly inheriting from object. --- materials.py | 4 ++-- mclevel.py | 4 ++-- nbt.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/materials.py b/materials.py index ed03321..83d648b 100644 --- a/materials.py +++ b/materials.py @@ -4,7 +4,7 @@ from materials import classicMaterials, materials from numpy import * NOTEX = 184 #wow, punching this map in would have been much easier in hex -class MCMaterials(): +class MCMaterials(object): def materialNamed(self, name): return self.names.index(name); @@ -423,4 +423,4 @@ def texCoords(idx): materials.blockTextures = array([map(texCoords, faces) for (faces, name) in materials.blockTextures], dtype='uint8') classicMaterials.blockTextures = array([map(texCoords, faces) for (faces, name) in classicMaterials.blockTextures], dtype='uint8') -alphaMaterials = materials; \ No newline at end of file +alphaMaterials = materials; diff --git a/mclevel.py b/mclevel.py index 0a45b4c..fb4d220 100644 --- a/mclevel.py +++ b/mclevel.py @@ -269,7 +269,7 @@ def decompress_first(func): return func(self, *args, **kw); return dec_first -class MCLevel: +class MCLevel(object): """ MCLevel is an abstract class providing many routines to the different level types, including a common copyEntitiesFrom built on class-specific routines, and a dummy getChunk/getPresentChunks for the finite levels. @@ -1188,7 +1188,7 @@ class PlayerNotFound(Exception): pass class ChunkNotPresent(Exception): pass class ChunkMalformed(ChunkNotPresent): pass -class ZeroChunk: +class ZeroChunk(object): " a placebo for neighboring-chunk routines " def compress(self): pass def load(self): pass diff --git a/nbt.py b/nbt.py index 455800b..0479e8b 100644 --- a/nbt.py +++ b/nbt.py @@ -23,7 +23,7 @@ import StringIO; from numpy import array, zeros, uint8, fromstring TAGfmt = ">b" -class TAG_Value: +class TAG_Value(object): """Simple values. Subclasses override fmt to change the type and size. Subclasses may set dataType instead of overriding setValue for automatic data type coercion""" From 47cf34bbfdce15df4a7724b51cd7cd60362995e8 Mon Sep 17 00:00:00 2001 From: Caleb Deveraux Date: Mon, 27 Sep 2010 10:33:51 +0800 Subject: [PATCH 2/3] Fix TAG_String's setValue and dataType member functions --- nbt.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nbt.py b/nbt.py index 0479e8b..c5a97ec 100644 --- a/nbt.py +++ b/nbt.py @@ -169,8 +169,7 @@ class TAG_String(TAG_Value): tag = 8; fmt = ">h%ds" - def setValue(self, val): - _value = str(val) + dataType = str def __init__(self, value="", name=None, data=""): self.name=name From 7292701e4d91a3fa47c5e2df67a0704fd327d37e Mon Sep 17 00:00:00 2001 From: Caleb Deveraux Date: Mon, 27 Sep 2010 10:42:53 +0800 Subject: [PATCH 3/3] Fix TAG_Byte_Array's setValue and dataType member functions --- nbt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nbt.py b/nbt.py index c5a97ec..ba9c2a4 100644 --- a/nbt.py +++ b/nbt.py @@ -141,8 +141,9 @@ class TAG_Byte_Array(TAG_Value): tag = 7; fmt = ">i%ds" - def setValue(self, val): - _value = numpy.array(val, uint8) + + def dataType(self, value): + return array(value, uint8) def __repr__(self): return "<%s: length %d> ( %s )" % (self.__class__, len(self.value), self.name)