Some instance type test improved
authorlbessard
Thu, 28 Aug 2008 14:28:41 +0200
changeset 513 f0343a7457b8
parent 512 e84806c0ada4
child 514 5ecc8f8090cb
Some instance type test improved
Bug with $NODEID not in uppercase fixed
objdictgen/eds_utils.py
objdictgen/node.py
--- a/objdictgen/eds_utils.py	Thu Aug 28 14:24:22 2008 +0200
+++ b/objdictgen/eds_utils.py	Thu Aug 28 14:28:41 2008 +0200
@@ -391,12 +391,12 @@
                     attributes = "Attribute \"%s\" is"%unsupported[0]
                 raise SyntaxError, "Error on section \"[%s]\":\n%s unsupported for a%s entry"%(section_name, attributes, ENTRY_TYPES[values["OBJECTTYPE"]]["name"])
             
-            VerifyValue(values, "ParameterValue")
-            VerifyValue(values, "DefaultValue")
+            VerifyValue(values, section_name, "ParameterValue")
+            VerifyValue(values, section_name, "DefaultValue")
             
     return eds_dict
 
-def VerifyValue(values, param):
+def VerifyValue(values, section_name, param):
     if param.upper() in values:
         try:
             if values["DATATYPE"] in (0x09, 0x0A, 0x0B, 0x0F):
@@ -406,7 +406,7 @@
             elif values["DATATYPE"] == 0x01:
                 values[param.upper()] = {0 : False, 1 : True}[values[param.upper()]]
             else:
-                if type(values[param.upper()]) != IntType and values[param.upper()].find("$NODEID") == -1:
+                if not isinstance(values[param.upper()], (IntType, LongType)) and values[param.upper()].upper().find("$NODEID") == -1:
                     raise
         except:
             raise SyntaxError, "Error on section \"[%s]\":\n%s incompatible with DataType"%(section_name, param)
--- a/objdictgen/node.py	Thu Aug 28 14:24:22 2008 +0200
+++ b/objdictgen/node.py	Thu Aug 28 14:28:41 2008 +0200
@@ -917,12 +917,12 @@
         return result
             
     def CompileValue(self, value, index, compute = True):
-        if type(value) == StringType and value.find("$NODEID") != -1:
+        if isinstance(value, (StringType, UnicodeType)) and value.find("$NODEID") != -1:
             base = self.GetBaseIndex(index)
             try:
                 raw = eval(value)
                 if compute:
-                    return eval(raw.replace("$NODEID","self.ID"))
+                    return eval(raw.upper().replace("$NODEID","self.ID"))
                 return raw
             except:
                 return 0