plcopen/plcopen.py
changeset 2439 f0a040f1de1b
parent 2437 105c20fdeb19
child 2447 1c04a50dc7ff
equal deleted inserted replaced
2438:0f2e5303f212 2439:f0a040f1de1b
    77     ("SD", True),
    77     ("SD", True),
    78     ("DS", True),
    78     ("DS", True),
    79     ("SL", True)])
    79     ("SL", True)])
    80 
    80 
    81 
    81 
    82 FILTER_ADDRESS_MODEL = "(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)"
    82 FILTER_ADDRESS_MODEL = r"(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)"
    83 
    83 
    84 
    84 
    85 def update_address(address, address_model, new_leading):
    85 def update_address(address, address_model, new_leading):
    86     result = address_model.match(address)
    86     result = address_model.match(address)
    87     if result is None:
    87     if result is None:
   229 def LoadProjectXML(project_xml):
   229 def LoadProjectXML(project_xml):
   230     project_xml = project_xml.replace(
   230     project_xml = project_xml.replace(
   231         "http://www.plcopen.org/xml/tc6.xsd",
   231         "http://www.plcopen.org/xml/tc6.xsd",
   232         "http://www.plcopen.org/xml/tc6_0201")
   232         "http://www.plcopen.org/xml/tc6_0201")
   233     for cre, repl in [
   233     for cre, repl in [
   234             (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
   234             (re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
   235             (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
   235             (re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
   236         project_xml = cre.sub(repl, project_xml)
   236         project_xml = cre.sub(repl, project_xml)
   237 
   237 
   238     try:
   238     try:
   239         tree, error = PLCOpenParser.LoadXMLString(project_xml)
   239         tree, error = PLCOpenParser.LoadXMLString(project_xml)
   240         if error is None:
   240         if error is None:
  2874     setattr(cls, "getvalue", getvalue)
  2874     setattr(cls, "getvalue", getvalue)
  2875 
  2875 
  2876 
  2876 
  2877 cls = PLCOpenParser.GetElementClass("arrayValue", "value")
  2877 cls = PLCOpenParser.GetElementClass("arrayValue", "value")
  2878 if cls:
  2878 if cls:
  2879     arrayValue_model = re.compile("([0-9]+)\((.*)\)$")
  2879     arrayValue_model = re.compile(r"([0-9]+)\((.*)\)$")
  2880     _updateArrayValueValueClass(cls)
  2880     _updateArrayValueValueClass(cls)
  2881 
  2881 
  2882 # ----------------------------------------------------------------------
  2882 # ----------------------------------------------------------------------
  2883 
  2883 
  2884 
  2884