summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2012-06-22 08:54:08 +0200
committerFlorian Bruhin <me@the-compiler.org>2012-06-22 08:54:08 +0200
commitfb33ac4ba6df519b23a490e92c6f0586669f54c9 (patch)
tree48f7ed89e083409d232126c2d332866cdc545bac
parenteac86d09fca10d08ac6c25c0e864a9602b9449a2 (diff)
downloadxdd2esi-fb33ac4ba6df519b23a490e92c6f0586669f54c9.tar.gz
xdd2esi-fb33ac4ba6df519b23a490e92c6f0586669f54c9.zip
Make _convert_cast_get_unit in xddlib a function, not a method
-rw-r--r--xddlib.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/xddlib.py b/xddlib.py
index 94bc432..3c886e9 100644
--- a/xddlib.py
+++ b/xddlib.py
@@ -144,7 +144,7 @@ class XDDFile:
def _convert_cast_attribute(self, obj, label, units):
""" Converts an attribute of an object to the right type """
value = getattr(obj, label)
- unit = self._convert_cast_get_unit(obj, units[label], value)
+ unit = _convert_cast_get_unit(obj, units[label], value)
convfuncs = {
'truefalse': _convert_cast_truefalse,
'boolean': _convert_cast_hexint,
@@ -169,21 +169,6 @@ class XDDFile:
newvalue = value
setattr(obj, label, newvalue)
- def _convert_cast_get_unit(self, obj, unit, value):
- """
- Gets the unit of an object attribute (from the datatype if needed)
- """
- if unit == 'dt': # If the unit is 'dt', get the real unit from the
- # datatype
- newunit = obj.datatype.type_
- # The datatype doesn't know hexint, but if an integer starts with
- # '0x' it's hexadecimal.
- if (newunit == 'integer') and value.startswith('0x'):
- newunit = 'hexint'
- else: # unit is already right
- newunit = unit
- return newunit
-
def _is_reserved(objdict):
""" Returns true if an object is reserved """
match = re.match('^reserved[0-9a-fA_F]*$', objdict['name'])
@@ -323,6 +308,21 @@ def _convert_datatypes(obj):
else:
handler(obj)
+def _convert_cast_get_unit(obj, unit, value):
+ """
+ Gets the unit of an object attribute (from the datatype if needed)
+ """
+ if unit == 'dt': # If the unit is 'dt', get the real unit from the
+ # datatype
+ newunit = obj.datatype.type_
+ # The datatype doesn't know hexint, but if an integer starts with
+ # '0x' it's hexadecimal.
+ if (newunit == 'integer') and value.startswith('0x'):
+ newunit = 'hexint'
+ else: # unit is already right
+ newunit = unit
+ return newunit
+
def _convert_cast_truefalse(value):
""" Converts to a python boolean """
conv = { 'true': True, 'false': False }