comparison gamelib/serializer.py @ 505:3ed6c011106d

Switch to classmethod decorators.
author Simon Cross <hodgestar@gmail.com>
date Thu, 26 Nov 2009 22:34:58 +0000
parents fdda0f3c956b
children 03be16420e8b
comparison
equal deleted inserted replaced
504:393e30ea0165 505:3ed6c011106d
98 __metaclass__ = SimplifiableMetaclass 98 __metaclass__ = SimplifiableMetaclass
99 99
100 # List of attributes which need to be stored and restored 100 # List of attributes which need to be stored and restored
101 SIMPLIFY = [] 101 SIMPLIFY = []
102 102
103 @classmethod
103 def make(cls): 104 def make(cls):
104 """ 105 """
105 Create an object of this class without any attributes set. 106 Create an object of this class without any attributes set.
106 """ 107 """
107 return cls.__new__(cls) 108 return cls.__new__(cls)
108 make = classmethod(make)
109 109
110 @classmethod
110 def unsimplify(cls, value, refs=None): 111 def unsimplify(cls, value, refs=None):
111 """ 112 """
112 Create an object of this class (or a sub-class) from its 113 Create an object of this class (or a sub-class) from its
113 simplification. 114 simplification.
114 """ 115 """
128 129
129 for attr, value in zip(actual_cls.SIMPLIFY, attrs): 130 for attr, value in zip(actual_cls.SIMPLIFY, attrs):
130 setattr(obj, attr, unsimplify(value, refs)) 131 setattr(obj, attr, unsimplify(value, refs))
131 132
132 return obj 133 return obj
133 unsimplify = classmethod(unsimplify)
134 134
135 def simplify(self, refs=None): 135 def simplify(self, refs=None):
136 """ 136 """
137 Create a simplified version (tar) of the object. 137 Create a simplified version (tar) of the object.
138 """ 138 """