comparison engine/extensions/pychan/attrs.py @ 188:06dddc96ce54

* Fixed some space and tab mixing * Fixed a small bug in manager.py, thanks to phoku for the pointer.
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 26 Feb 2009 11:26:01 +0000
parents fe7ff4808529
children 756b895e1dab
comparison
equal deleted inserted replaced
187:644bf7ca1e0a 188:06dddc96ce54
8 an attribute of an object accepts. 8 an attribute of an object accepts.
9 9
10 Usage:: 10 Usage::
11 class SomeObject: 11 class SomeObject:
12 nameAttr, posAttr = [ Attr("name"), PointAttr("pos") ] 12 nameAttr, posAttr = [ Attr("name"), PointAttr("pos") ]
13 13
14 obj = SomeObject() 14 obj = SomeObject()
15 obj.nameAttr.set(obj,"newName") 15 obj.nameAttr.set(obj,"newName")
16 obj.posAttr.set(obj,"89,89") 16 obj.posAttr.set(obj,"89,89")
17 17
18 This is most useful for error checking parsing and defining 18 This is most useful for error checking parsing and defining
83 if value not in (0,1): 83 if value not in (0,1):
84 raise ParserError("Expected a 0 or 1.") 84 raise ParserError("Expected a 0 or 1.")
85 return value 85 return value
86 except: 86 except:
87 raise ParserError("Expected a 0 or 1.") 87 raise ParserError("Expected a 0 or 1.")
88 88
89 class FloatAttr(Attr): 89 class FloatAttr(Attr):
90 def parse(self, value): 90 def parse(self, value):
91 try: 91 try:
92 return float(value) 92 return float(value)
93 except: 93 except: