152 text = text[:result.start()] + new_address + text[result.end():] |
152 text = text[:result.start()] + new_address + text[result.end():] |
153 startpos = result.start() + len(new_address) |
153 startpos = result.start() + len(new_address) |
154 result = address_model.search(self.text, startpos) |
154 result = address_model.search(self.text, startpos) |
155 self.text = text |
155 self.text = text |
156 setattr(cls, "updateElementAddress", updateElementAddress) |
156 setattr(cls, "updateElementAddress", updateElementAddress) |
|
157 |
|
158 def hasblock(self, block_type): |
|
159 text = self.text.upper() |
|
160 index = text.find(block_type.upper()) |
|
161 while index != -1: |
|
162 if (not (index > 0 and (text[index - 1].isalnum() or text[index - 1] == "_")) and |
|
163 not (index < len(text) - len(block_type) and text[index + len(block_type)] != "(")): |
|
164 return True |
|
165 index = text.find(block_type.upper(), index + len(block_type)) |
|
166 return False |
|
167 setattr(cls, "hasblock", hasblock) |
157 |
168 |
158 def Search(self, criteria, parent_infos): |
169 def Search(self, criteria, parent_infos): |
159 return [(tuple(parent_infos),) + result for result in TestTextElement(self.gettext(), criteria)] |
170 return [(tuple(parent_infos),) + result for result in TestTextElement(self.gettext(), criteria)] |
160 setattr(cls, "Search", Search) |
171 setattr(cls, "Search", Search) |
161 |
172 |
487 block_infos["usage"] = "\n (%s) => (%s)" % (", ".join(["%s:%s" % (input[1], input[0]) for input in block_infos["inputs"]]), |
498 block_infos["usage"] = "\n (%s) => (%s)" % (", ".join(["%s:%s" % (input[1], input[0]) for input in block_infos["inputs"]]), |
488 ", ".join(["%s:%s" % (output[1], output[0]) for output in block_infos["outputs"]])) |
499 ", ".join(["%s:%s" % (output[1], output[0]) for output in block_infos["outputs"]])) |
489 self.CustomBlockTypes.append(block_infos) |
500 self.CustomBlockTypes.append(block_infos) |
490 setattr(cls, "AddCustomBlockType", AddCustomBlockType) |
501 setattr(cls, "AddCustomBlockType", AddCustomBlockType) |
491 |
502 |
|
503 def AddElementUsingTreeInstance(self, name, type_infos): |
|
504 typename = type_infos.getname() |
|
505 if not self.ElementUsingTree.has_key(typename): |
|
506 self.ElementUsingTree[typename] = [name] |
|
507 elif name not in self.ElementUsingTree[typename]: |
|
508 self.ElementUsingTree[typename].append(name) |
|
509 setattr(cls, "AddElementUsingTreeInstance", AddElementUsingTreeInstance) |
|
510 |
492 def RefreshElementUsingTree(self): |
511 def RefreshElementUsingTree(self): |
493 # Reset the tree of user-defined element cross-use |
512 # Reset the tree of user-defined element cross-use |
494 self.ElementUsingTree = {} |
513 self.ElementUsingTree = {} |
495 pous = self.getpous() |
514 pous = self.getpous() |
496 datatypes = self.getdataTypes() |
515 datatypes = self.getdataTypes() |
497 # Reference all the user-defined elementu names and initialize the tree of |
|
498 # user-defined elemnt cross-use |
|
499 elementnames = [datatype.getname() for datatype in datatypes] + \ |
|
500 [pou.getname() for pou in pous] |
|
501 for name in elementnames: |
|
502 self.ElementUsingTree[name] = [] |
|
503 # Analyze each datatype |
516 # Analyze each datatype |
504 for datatype in datatypes: |
517 for datatype in datatypes: |
505 name = datatype.getname() |
518 name = datatype.getname() |
506 basetype_content = datatype.baseType.getcontent() |
519 basetype_content = datatype.baseType.getcontent() |
507 if basetype_content["name"] == "derived": |
520 if basetype_content["name"] == "derived": |
509 if name in self.ElementUsingTree[typename]: |
522 if name in self.ElementUsingTree[typename]: |
510 self.ElementUsingTree[typename].append(name) |
523 self.ElementUsingTree[typename].append(name) |
511 elif basetype_content["name"] in ["subrangeSigned", "subrangeUnsigned", "array"]: |
524 elif basetype_content["name"] in ["subrangeSigned", "subrangeUnsigned", "array"]: |
512 base_type = basetype_content["value"].baseType.getcontent() |
525 base_type = basetype_content["value"].baseType.getcontent() |
513 if base_type["name"] == "derived": |
526 if base_type["name"] == "derived": |
514 typename = base_type["value"].getname() |
527 self.AddElementUsingTreeInstance(name, base_type["value"]) |
515 if self.ElementUsingTree.has_key(typename) and name not in self.ElementUsingTree[typename]: |
|
516 self.ElementUsingTree[typename].append(name) |
|
517 elif basetype_content["name"] == "struct": |
528 elif basetype_content["name"] == "struct": |
518 for element in basetype_content["value"].getvariable(): |
529 for element in basetype_content["value"].getvariable(): |
519 type_content = element.type.getcontent() |
530 type_content = element.type.getcontent() |
520 if type_content["name"] == "derived": |
531 if type_content["name"] == "derived": |
521 typename = type_content["value"].getname() |
532 self.AddElementUsingTreeInstance(name, type_content["value"]) |
522 if self.ElementUsingTree.has_key(typename) and name not in self.ElementUsingTree[typename]: |
|
523 self.ElementUsingTree[typename].append(name) |
|
524 # Analyze each pou |
533 # Analyze each pou |
525 for pou in pous: |
534 for pou in pous: |
526 name = pou.getname() |
535 name = pou.getname() |
527 if pou.interface: |
536 if pou.interface: |
528 # Extract variables from every varLists |
537 # Extract variables from every varLists |
529 for type, varlist in pou.getvars(): |
538 for type, varlist in pou.getvars(): |
530 for var in varlist.getvariable(): |
539 for var in varlist.getvariable(): |
531 vartype_content = var.gettype().getcontent() |
540 vartype_content = var.gettype().getcontent() |
532 if vartype_content["name"] == "derived": |
541 if vartype_content["name"] == "derived": |
533 typename = vartype_content["value"].getname() |
542 self.AddElementUsingTreeInstance(name, vartype_content["value"]) |
534 if self.ElementUsingTree.has_key(typename) and name not in self.ElementUsingTree[typename]: |
543 for typename in self.ElementUsingTree.iterkeys(): |
535 self.ElementUsingTree[typename].append(name) |
544 if typename != name and pou.hasblock(block_type=typename) and name not in self.ElementUsingTree[typename]: |
|
545 self.ElementUsingTree[typename].append(name) |
|
546 |
536 setattr(cls, "RefreshElementUsingTree", RefreshElementUsingTree) |
547 setattr(cls, "RefreshElementUsingTree", RefreshElementUsingTree) |
537 |
548 |
538 def GetParentType(self, type): |
549 def GetParentType(self, type): |
539 if self.CustomTypeHierarchy.has_key(type): |
550 if self.CustomTypeHierarchy.has_key(type): |
540 return self.CustomTypeHierarchy[type] |
551 return self.CustomTypeHierarchy[type] |
838 var_number += 1 |
849 var_number += 1 |
839 return search_result |
850 return search_result |
840 |
851 |
841 cls = PLCOpenClasses.get("configurations_configuration", None) |
852 cls = PLCOpenClasses.get("configurations_configuration", None) |
842 if cls: |
853 if cls: |
|
854 |
|
855 def addglobalVar(self, type, name, location="", description=""): |
|
856 globalvars = self.getglobalVars() |
|
857 if len(globalvars) == 0: |
|
858 globalvars.append(PLCOpenClasses["varList"]()) |
|
859 var = PLCOpenClasses["varListPlain_variable"]() |
|
860 var.setname(name) |
|
861 var_type = PLCOpenClasses["dataType"]() |
|
862 if type in [x for x,y in TypeHierarchy_list if not x.startswith("ANY")]: |
|
863 if type == "STRING": |
|
864 var_type.setcontent({"name" : "string", "value" : PLCOpenClasses["elementaryTypes_string"]()}) |
|
865 elif type == "WSTRING": |
|
866 var_type.setcontent({"name" : "wstring", "value" : PLCOpenClasses["elementaryTypes_wstring"]()}) |
|
867 else: |
|
868 var_type.setcontent({"name" : type, "value" : None}) |
|
869 else: |
|
870 derived_type = PLCOpenClasses["derivedTypes_derived"]() |
|
871 derived_type.setname(type) |
|
872 var_type.setcontent({"name" : "derived", "value" : derived_type}) |
|
873 var.settype(var_type) |
|
874 if location != "": |
|
875 var.setaddress(location) |
|
876 if description != "": |
|
877 ft = PLCOpenClasses["formattedText"]() |
|
878 ft.settext(description) |
|
879 var.setdocumentation(ft) |
|
880 globalvars[-1].appendvariable(var) |
|
881 setattr(cls, "addglobalVar", addglobalVar) |
|
882 |
843 def updateElementName(self, old_name, new_name): |
883 def updateElementName(self, old_name, new_name): |
844 _updateConfigurationResourceElementName(self, old_name, new_name) |
884 _updateConfigurationResourceElementName(self, old_name, new_name) |
845 for resource in self.getresource(): |
885 for resource in self.getresource(): |
846 resource.updateElementName(old_name, new_name) |
886 resource.updateElementName(old_name, new_name) |
847 setattr(cls, "updateElementName", updateElementName) |
887 setattr(cls, "updateElementName", updateElementName) |
1380 if len(varlist["value"].getvariable()) == 0: |
1420 if len(varlist["value"].getvariable()) == 0: |
1381 content.remove(varlist) |
1421 content.remove(varlist) |
1382 break |
1422 break |
1383 setattr(cls, "removepouVar", removepouVar) |
1423 setattr(cls, "removepouVar", removepouVar) |
1384 |
1424 |
1385 def hasblock(self, name): |
1425 def hasblock(self, name=None, block_type=None): |
1386 if self.getbodyType() in ["FBD", "LD", "SFC"]: |
1426 if self.getbodyType() in ["FBD", "LD", "SFC"]: |
1387 for instance in self.getinstances(): |
1427 for instance in self.getinstances(): |
1388 if isinstance(instance, PLCOpenClasses["fbdObjects_block"]) and instance.getinstanceName() == name: |
1428 if (isinstance(instance, PLCOpenClasses["fbdObjects_block"]) and |
|
1429 (name and instance.getinstanceName() == name or |
|
1430 block_type and instance.gettypeName() == block_type)): |
1389 return True |
1431 return True |
1390 if self.transitions: |
1432 if self.transitions: |
1391 for transition in self.transitions.gettransition(): |
1433 for transition in self.transitions.gettransition(): |
1392 result = transition.hasblock(name) |
1434 result = transition.hasblock(name, block_type) |
1393 if result: |
1435 if result: |
1394 return result |
1436 return result |
1395 if self.actions: |
1437 if self.actions: |
1396 for action in self.actions.getaction(): |
1438 for action in self.actions.getaction(): |
1397 result = action.hasblock(name) |
1439 result = action.hasblock(name, block_type) |
1398 if result: |
1440 if result: |
1399 return result |
1441 return result |
|
1442 elif block_type is not None and len(self.body) > 0: |
|
1443 return self.body[0].hasblock(block_type) |
1400 return False |
1444 return False |
1401 setattr(cls, "hasblock", hasblock) |
1445 setattr(cls, "hasblock", hasblock) |
1402 |
1446 |
1403 def addtransition(self, name, type): |
1447 def addtransition(self, name, type): |
1404 if not self.transitions: |
1448 if not self.transitions: |
1624 self.body.settext(text) |
1668 self.body.settext(text) |
1625 |
1669 |
1626 def gettext(self): |
1670 def gettext(self): |
1627 return self.body.gettext() |
1671 return self.body.gettext() |
1628 |
1672 |
|
1673 def hasblock(self, name=None, block_type=None): |
|
1674 if self.getbodyType() in ["FBD", "LD", "SFC"]: |
|
1675 for instance in self.getinstances(): |
|
1676 if (isinstance(instance, PLCOpenClasses["fbdObjects_block"]) and |
|
1677 (name and instance.getinstanceName() == name or |
|
1678 block_type and instance.gettypeName() == block_type)): |
|
1679 return True |
|
1680 elif block_type is not None: |
|
1681 return self.body.hasblock(block_type) |
|
1682 return False |
|
1683 |
|
1684 def updateElementName(self, old_name, new_name): |
|
1685 self.body.updateElementName(old_name, new_name) |
|
1686 |
|
1687 def updateElementAddress(self, address_model, new_leading): |
|
1688 self.body.updateElementAddress(address_model, new_leading) |
|
1689 |
|
1690 |
1629 cls = PLCOpenClasses.get("transitions_transition", None) |
1691 cls = PLCOpenClasses.get("transitions_transition", None) |
1630 if cls: |
1692 if cls: |
1631 setattr(cls, "setbodyType", setbodyType) |
1693 setattr(cls, "setbodyType", setbodyType) |
1632 setattr(cls, "getbodyType", getbodyType) |
1694 setattr(cls, "getbodyType", getbodyType) |
1633 setattr(cls, "resetexecutionOrder", resetexecutionOrder) |
1695 setattr(cls, "resetexecutionOrder", resetexecutionOrder) |
1639 setattr(cls, "getrandomInstance", getrandomInstance) |
1701 setattr(cls, "getrandomInstance", getrandomInstance) |
1640 setattr(cls, "getinstanceByName", getinstanceByName) |
1702 setattr(cls, "getinstanceByName", getinstanceByName) |
1641 setattr(cls, "removeinstance", removeinstance) |
1703 setattr(cls, "removeinstance", removeinstance) |
1642 setattr(cls, "settext", settext) |
1704 setattr(cls, "settext", settext) |
1643 setattr(cls, "gettext", gettext) |
1705 setattr(cls, "gettext", gettext) |
1644 |
1706 setattr(cls, "hasblock", hasblock) |
1645 def updateElementName(self, old_name, new_name): |
|
1646 self.body.updateElementName(old_name, new_name) |
|
1647 setattr(cls, "updateElementName", updateElementName) |
1707 setattr(cls, "updateElementName", updateElementName) |
1648 |
|
1649 def updateElementAddress(self, address_model, new_leading): |
|
1650 self.body.updateElementAddress(address_model, new_leading) |
|
1651 setattr(cls, "updateElementAddress", updateElementAddress) |
1708 setattr(cls, "updateElementAddress", updateElementAddress) |
1652 |
1709 |
1653 def hasblock(self, name): |
|
1654 if self.getbodyType() in ["FBD", "LD", "SFC"]: |
|
1655 for instance in self.getinstances(): |
|
1656 if isinstance(instance, PLCOpenClasses["fbdObjects_block"]) and instance.getinstanceName() == name: |
|
1657 return True |
|
1658 return False |
|
1659 setattr(cls, "hasblock", hasblock) |
|
1660 |
|
1661 def Search(self, criteria, parent_infos): |
1710 def Search(self, criteria, parent_infos): |
1662 search_result = [] |
1711 search_result = [] |
1663 parent_infos = parent_infos[:-1] + ["T::%s::%s" % (parent_infos[-1].split("::")[1], self.getname())] |
1712 parent_infos = parent_infos[:-1] + ["T::%s::%s" % (parent_infos[-1].split("::")[1], self.getname())] |
1664 for result in TestTextElement(self.getname(), criteria): |
1713 for result in TestTextElement(self.getname(), criteria): |
1665 search_result.append((tuple(parent_infos + ["name"]),) + result) |
1714 search_result.append((tuple(parent_infos + ["name"]),) + result) |
1680 setattr(cls, "getrandomInstance", getrandomInstance) |
1729 setattr(cls, "getrandomInstance", getrandomInstance) |
1681 setattr(cls, "getinstanceByName", getinstanceByName) |
1730 setattr(cls, "getinstanceByName", getinstanceByName) |
1682 setattr(cls, "removeinstance", removeinstance) |
1731 setattr(cls, "removeinstance", removeinstance) |
1683 setattr(cls, "settext", settext) |
1732 setattr(cls, "settext", settext) |
1684 setattr(cls, "gettext", gettext) |
1733 setattr(cls, "gettext", gettext) |
1685 |
1734 setattr(cls, "hasblock", hasblock) |
1686 def updateElementName(self, old_name, new_name): |
|
1687 self.body.updateElementName(old_name, new_name) |
|
1688 setattr(cls, "updateElementName", updateElementName) |
1735 setattr(cls, "updateElementName", updateElementName) |
1689 |
|
1690 def updateElementAddress(self, address_model, new_leading): |
|
1691 self.body.updateElementAddress(address_model, new_leading) |
|
1692 setattr(cls, "updateElementAddress", updateElementAddress) |
1736 setattr(cls, "updateElementAddress", updateElementAddress) |
1693 |
1737 |
1694 def hasblock(self, name): |
|
1695 if self.getbodyType() in ["FBD", "LD", "SFC"]: |
|
1696 for instance in self.getinstances(): |
|
1697 if isinstance(instance, PLCOpenClasses["fbdObjects_block"]) and instance.getinstanceName() == name: |
|
1698 return True |
|
1699 return False |
|
1700 setattr(cls, "hasblock", hasblock) |
|
1701 |
|
1702 def Search(self, criteria, parent_infos): |
1738 def Search(self, criteria, parent_infos): |
1703 search_result = [] |
1739 search_result = [] |
1704 parent_infos = parent_infos[:-1] + ["A::%s::%s" % (parent_infos[-1].split("::")[1], self.getname())] |
1740 parent_infos = parent_infos[:-1] + ["A::%s::%s" % (parent_infos[-1].split("::")[1], self.getname())] |
1705 for result in TestTextElement(self.getname(), criteria): |
1741 for result in TestTextElement(self.getname(), criteria): |
1706 search_result.append((tuple(parent_infos + ["name"]),) + result) |
1742 search_result.append((tuple(parent_infos + ["name"]),) + result) |
1709 setattr(cls, "Search", Search) |
1745 setattr(cls, "Search", Search) |
1710 |
1746 |
1711 cls = PLCOpenClasses.get("body", None) |
1747 cls = PLCOpenClasses.get("body", None) |
1712 if cls: |
1748 if cls: |
1713 cls.currentExecutionOrderId = 0 |
1749 cls.currentExecutionOrderId = 0 |
|
1750 cls.instances_dict = {} |
|
1751 |
|
1752 setattr(cls, "_init_", getattr(cls, "__init__")) |
|
1753 |
|
1754 def __init__(self, *args, **kwargs): |
|
1755 self._init_(*args, **kwargs) |
|
1756 self.instances_dict = {} |
|
1757 setattr(cls, "__init__", __init__) |
|
1758 |
|
1759 setattr(cls, "_loadXMLTree", getattr(cls, "loadXMLTree")) |
|
1760 |
|
1761 def loadXMLTree(self, *args, **kwargs): |
|
1762 self._loadXMLTree(*args, **kwargs) |
|
1763 if self.content["name"] in ["LD","FBD","SFC"]: |
|
1764 self.instances_dict = dict( |
|
1765 [(element["value"].getlocalId(), element) |
|
1766 for element in self.content["value"].getcontent()]) |
|
1767 setattr(cls, "loadXMLTree", loadXMLTree) |
1714 |
1768 |
1715 def resetcurrentExecutionOrderId(self): |
1769 def resetcurrentExecutionOrderId(self): |
1716 object.__setattr__(self, "currentExecutionOrderId", 0) |
1770 object.__setattr__(self, "currentExecutionOrderId", 0) |
1717 setattr(cls, "resetcurrentExecutionOrderId", resetcurrentExecutionOrderId) |
1771 setattr(cls, "resetcurrentExecutionOrderId", resetcurrentExecutionOrderId) |
1718 |
1772 |
1783 raise TypeError, _("Can only generate execution order on FBD networks!") |
1837 raise TypeError, _("Can only generate execution order on FBD networks!") |
1784 setattr(cls, "setelementExecutionOrder", setelementExecutionOrder) |
1838 setattr(cls, "setelementExecutionOrder", setelementExecutionOrder) |
1785 |
1839 |
1786 def appendcontentInstance(self, name, instance): |
1840 def appendcontentInstance(self, name, instance): |
1787 if self.content["name"] in ["LD","FBD","SFC"]: |
1841 if self.content["name"] in ["LD","FBD","SFC"]: |
1788 self.content["value"].appendcontent({"name" : name, "value" : instance}) |
1842 element = {"name" : name, "value" : instance} |
|
1843 self.content["value"].appendcontent(element) |
|
1844 self.instances_dict[instance.getlocalId()] = element |
1789 else: |
1845 else: |
1790 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1846 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1791 setattr(cls, "appendcontentInstance", appendcontentInstance) |
1847 setattr(cls, "appendcontentInstance", appendcontentInstance) |
1792 |
1848 |
1793 def getcontentInstances(self): |
1849 def getcontentInstances(self): |
1800 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1856 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1801 setattr(cls, "getcontentInstances", getcontentInstances) |
1857 setattr(cls, "getcontentInstances", getcontentInstances) |
1802 |
1858 |
1803 def getcontentInstance(self, id): |
1859 def getcontentInstance(self, id): |
1804 if self.content["name"] in ["LD","FBD","SFC"]: |
1860 if self.content["name"] in ["LD","FBD","SFC"]: |
1805 for element in self.content["value"].getcontent(): |
1861 instance = self.instances_dict.get(id, None) |
1806 if element["value"].getlocalId() == id: |
1862 if instance is not None: |
1807 return element["value"] |
1863 return instance["value"] |
1808 return None |
1864 return None |
1809 else: |
1865 else: |
1810 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1866 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1811 setattr(cls, "getcontentInstance", getcontentInstance) |
1867 setattr(cls, "getcontentInstance", getcontentInstance) |
1812 |
1868 |
1813 def getcontentRandomInstance(self, exclude): |
1869 def getcontentRandomInstance(self, exclude): |
1814 if self.content["name"] in ["LD","FBD","SFC"]: |
1870 if self.content["name"] in ["LD","FBD","SFC"]: |
1815 for element in self.content["value"].getcontent(): |
1871 ids = self.instances_dict.viewkeys() - exclude |
1816 if element["value"].getlocalId() not in exclude: |
1872 if len(ids) > 0: |
1817 return element["value"] |
1873 return self.instances_dict[ids.pop()]["value"] |
1818 return None |
1874 return None |
1819 else: |
1875 else: |
1820 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1876 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1821 setattr(cls, "getcontentRandomInstance", getcontentRandomInstance) |
1877 setattr(cls, "getcontentRandomInstance", getcontentRandomInstance) |
1822 |
1878 |
1829 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1885 raise TypeError, _("%s body don't have instances!")%self.content["name"] |
1830 setattr(cls, "getcontentInstanceByName", getcontentInstanceByName) |
1886 setattr(cls, "getcontentInstanceByName", getcontentInstanceByName) |
1831 |
1887 |
1832 def removecontentInstance(self, id): |
1888 def removecontentInstance(self, id): |
1833 if self.content["name"] in ["LD","FBD","SFC"]: |
1889 if self.content["name"] in ["LD","FBD","SFC"]: |
1834 i = 0 |
1890 element = self.instances_dict.pop(id, None) |
1835 removed = False |
1891 if element is not None: |
1836 elements = self.content["value"].getcontent() |
1892 self.content["value"].getcontent().remove(element) |
1837 while i < len(elements) and not removed: |
1893 else: |
1838 if elements[i]["value"].getlocalId() == id: |
|
1839 self.content["value"].removecontent(i) |
|
1840 removed = True |
|
1841 i += 1 |
|
1842 if not removed: |
|
1843 raise ValueError, _("Instance with id %d doesn't exist!")%id |
1894 raise ValueError, _("Instance with id %d doesn't exist!")%id |
1844 else: |
1895 else: |
1845 raise TypeError, "%s body don't have instances!"%self.content["name"] |
1896 raise TypeError, "%s body don't have instances!"%self.content["name"] |
1846 setattr(cls, "removecontentInstance", removecontentInstance) |
1897 setattr(cls, "removecontentInstance", removecontentInstance) |
1847 |
1898 |
1856 if self.content["name"] in ["IL","ST"]: |
1907 if self.content["name"] in ["IL","ST"]: |
1857 return self.content["value"].gettext() |
1908 return self.content["value"].gettext() |
1858 else: |
1909 else: |
1859 raise TypeError, _("%s body don't have text!")%self.content["name"] |
1910 raise TypeError, _("%s body don't have text!")%self.content["name"] |
1860 setattr(cls, "gettext", gettext) |
1911 setattr(cls, "gettext", gettext) |
|
1912 |
|
1913 def hasblock(self, block_type): |
|
1914 if self.content["name"] in ["IL","ST"]: |
|
1915 return self.content["value"].hasblock(block_type) |
|
1916 else: |
|
1917 raise TypeError, _("%s body don't have text!")%self.content["name"] |
|
1918 setattr(cls, "hasblock", hasblock) |
1861 |
1919 |
1862 def updateElementName(self, old_name, new_name): |
1920 def updateElementName(self, old_name, new_name): |
1863 if self.content["name"] in ["IL", "ST"]: |
1921 if self.content["name"] in ["IL", "ST"]: |
1864 self.content["value"].updateElementName(old_name, new_name) |
1922 self.content["value"].updateElementName(old_name, new_name) |
1865 else: |
1923 else: |