objdictgen/eds_utils.py
changeset 227 f76c64f66097
parent 226 abf63d732a84
child 258 8f7725451453
equal deleted inserted replaced
226:abf63d732a84 227:f76c64f66097
   375                 if len(unsupported) > 1:
   375                 if len(unsupported) > 1:
   376                     attributes = "Attributes %s are"%", ".join(["\"%s\""%attribute for attribute in unsupported])
   376                     attributes = "Attributes %s are"%", ".join(["\"%s\""%attribute for attribute in unsupported])
   377                 else:
   377                 else:
   378                     attributes = "Attribute \"%s\" is"%unsupported[0]
   378                     attributes = "Attribute \"%s\" is"%unsupported[0]
   379                 raise SyntaxError, "Error on section \"[%s]\":\n%s unsupported for a%s entry"%(section_name, attributes, ENTRY_TYPES[objecttype]["name"])
   379                 raise SyntaxError, "Error on section \"[%s]\":\n%s unsupported for a%s entry"%(section_name, attributes, ENTRY_TYPES[objecttype]["name"])
   380         
   380             
       
   381             if "DEFAULTVALUE" in values:
       
   382                 try:
       
   383                     if values["DATATYPE"] in (0x09, 0x0A, 0x0B, 0x0F):
       
   384                         values["DEFAULTVALUE"] = str(values["DEFAULTVALUE"])
       
   385                     elif values["DATATYPE"] in (0x08, 0x11):
       
   386                         values["DEFAULTVALUE"] = float(values["DEFAULTVALUE"])
       
   387                     elif values["DATATYPE"] == 0x01:
       
   388                         values["DEFAULTVALUE"] = {0 : True, 1 : False}[values["DEFAULTVALUE"]]
       
   389                     else:
       
   390                         if type(values["DEFAULTVALUE"]) != IntType and values["DEFAULTVALUE"].find("self.ID") == -1:
       
   391                             raise
       
   392                 except:
       
   393                     raise SyntaxError, "Error on section \"[%s]\":\nDefaultValue incompatible with DataType"%section_name
       
   394             
   381     return eds_dict
   395     return eds_dict
   382 
   396 
   383 
   397 
   384 # Function that write an EDS file after generate it's content
   398 # Function that write an EDS file after generate it's content
   385 def WriteFile(filepath, content):
   399 def WriteFile(filepath, content):