plcopen/plcopen.py
changeset 431 c1c92d068ac5
parent 427 22d16c457d87
child 435 893d04aff708
equal deleted inserted replaced
411:9ab97d517ae8 431:c1c92d068ac5
   740         if tree.hasAttribute("type"):
   740         if tree.hasAttribute("type"):
   741             NodeRenameAttr(tree, "type", "typeName")
   741             NodeRenameAttr(tree, "type", "typeName")
   742     setattr(cls, "compatibility", compatibility)
   742     setattr(cls, "compatibility", compatibility)
   743     
   743     
   744     def updateElementName(self, old_name, new_name):
   744     def updateElementName(self, old_name, new_name):
   745         if self.type == old_name:
   745         if self.typeName == old_name:
   746             self.type = new_name
   746             self.typeName = new_name
   747     setattr(cls, "updateElementName", updateElementName)
   747     setattr(cls, "updateElementName", updateElementName)
   748 
   748 
   749 cls = PLCOpenClasses.get("project_types", None)
   749 cls = PLCOpenClasses.get("project_types", None)
   750 if cls:
   750 if cls:
   751     def getdataTypeElements(self):
   751     def getdataTypeElements(self):
  1030                 if transitions[i].getname() == name:
  1030                 if transitions[i].getname() == name:
  1031                     transitions.pop(i)
  1031                     transitions.pop(i)
  1032                     removed = True
  1032                     removed = True
  1033                 i += 1
  1033                 i += 1
  1034             if not removed:
  1034             if not removed:
  1035                 raise ValueError, _("Transition with name %s doesn't exists!")%name
  1035                 raise ValueError, _("Transition with name %s doesn't exist!")%name
  1036     setattr(cls, "removetransition", removetransition)
  1036     setattr(cls, "removetransition", removetransition)
  1037 
  1037 
  1038     def addaction(self, name, type):
  1038     def addaction(self, name, type):
  1039         if not self.actions:
  1039         if not self.actions:
  1040             self.addactions()
  1040             self.addactions()
  1068                 if actions[i].getname() == name:
  1068                 if actions[i].getname() == name:
  1069                     actions.pop(i)
  1069                     actions.pop(i)
  1070                     removed = True
  1070                     removed = True
  1071                 i += 1
  1071                 i += 1
  1072             if not removed:
  1072             if not removed:
  1073                 raise ValueError, _("Action with name %s doesn't exists!")%name
  1073                 raise ValueError, _("Action with name %s doesn't exist!")%name
  1074     setattr(cls, "removeaction", removeaction)
  1074     setattr(cls, "removeaction", removeaction)
  1075 
  1075 
  1076     def updateElementName(self, old_name, new_name):
  1076     def updateElementName(self, old_name, new_name):
  1077         if self.interface:
  1077         if self.interface:
  1078             for content in self.interface.getcontent():
  1078             for content in self.interface.getcontent():
  1324                 if elements[i]["value"].getlocalId() == id:
  1324                 if elements[i]["value"].getlocalId() == id:
  1325                     self.content["value"].removecontent(i)
  1325                     self.content["value"].removecontent(i)
  1326                     removed = True
  1326                     removed = True
  1327                 i += 1
  1327                 i += 1
  1328             if not removed:
  1328             if not removed:
  1329                 raise ValueError, _("Instance with id %d doesn't exists!")%id
  1329                 raise ValueError, _("Instance with id %d doesn't exist!")%id
  1330         else:
  1330         else:
  1331             raise TypeError, "%s body don't have instances!"%self.content["name"]
  1331             raise TypeError, "%s body don't have instances!"%self.content["name"]
  1332     setattr(cls, "removecontentInstance", removecontentInstance)
  1332     setattr(cls, "removecontentInstance", removecontentInstance)
  1333     
  1333     
  1334     def settext(self, text):
  1334     def settext(self, text):