Fix pep8 warning: W605 invalid escape sequence ‘x’
--- a/Beremiz_service.py Tue Oct 09 11:43:39 2018 +0300
+++ b/Beremiz_service.py Tue Oct 09 11:56:45 2018 +0300
@@ -328,7 +328,7 @@
ip_addr = self.pyroserver.ip_addr
ip_addr = '' if ip_addr is None else ip_addr
dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=ip_addr)
- dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")),
+ dlg.SetTests([(re.compile(r'\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")), (lambda x:len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4,
if dlg.ShowModal() == wx.ID_OK:
--- a/CodeFileTreeNode.py Tue Oct 09 11:43:39 2018 +0300
+++ b/CodeFileTreeNode.py Tue Oct 09 11:56:45 2018 +0300
@@ -114,8 +114,8 @@
'<%s>' % self.CODEFILE_NAME,
'<%s xmlns:xhtml="http://www.w3.org/1999/xhtml">' % self.CODEFILE_NAME)
- (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
- (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
+ (re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["), + (re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]: codefile_xml = cre.sub(repl, codefile_xml)
--- a/PLCControler.py Tue Oct 09 11:43:39 2018 +0300
+++ b/PLCControler.py Tue Oct 09 11:56:45 2018 +0300
@@ -44,8 +44,8 @@
from graphics.GraphicCommons import *
from PLCGenerator import *
-duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:\.[0-9]*)?)ms)?")
-VARIABLE_NAME_SUFFIX_MODEL = re.compile('(\d+)$')
+duration_model = re.compile(r"(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:\.[0-9]*)?)ms)?") +VARIABLE_NAME_SUFFIX_MODEL = re.compile(r'(\d+)$') ScriptDirectory = paths.AbsDir(__file__)
--- a/ProjectController.py Tue Oct 09 11:43:39 2018 +0300
+++ b/ProjectController.py Tue Oct 09 11:56:45 2018 +0300
@@ -68,7 +68,7 @@
base_folder = paths.AbsParentDir(__file__)
MATIEC_ERROR_MODEL = re.compile(
- ".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$")
+ r".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$") def ExtractChildrenTypesFromCatalog(catalog):
@@ -713,7 +713,7 @@
lines = [line.strip() for line in location_file.readlines()]
# This regular expression parses the lines genereated by IEC2C
LOCATED_MODEL = re.compile(
- "__LOCATED_VAR\((?P<IEC_TYPE>[A-Z]*),(?P<NAME>[_A-Za-z0-9]*),(?P<DIR>[QMI])(?:,(?P<SIZE>[XBWDL]))?,(?P<LOC>[,0-9]*)\)")
+ r"__LOCATED_VAR\((?P<IEC_TYPE>[A-Z]*),(?P<NAME>[_A-Za-z0-9]*),(?P<DIR>[QMI])(?:,(?P<SIZE>[XBWDL]))?,(?P<LOC>[,0-9]*)\)") result = LOCATED_MODEL.match(line)
--- a/controls/VariablePanel.py Tue Oct 09 11:43:39 2018 +0300
+++ b/controls/VariablePanel.py Tue Oct 09 11:56:45 2018 +0300
@@ -101,8 +101,8 @@
"External": lambda x: {"Constant": "Constant"}.get(x, "")
-LOCATION_MODEL = re.compile("((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$")
-LOCATION_MODEL_SET = re.compile("((?:%[IQM](?:[XBWLD]?[0-9]+(?:\.[0-9]+)*))?)$")
+LOCATION_MODEL = re.compile(r"((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$") +LOCATION_MODEL_SET = re.compile(r"((?:%[IQM](?:[XBWLD]?[0-9]+(?:\.[0-9]+)*))?)$") # -------------------------------------------------------------------------------
@@ -606,7 +606,7 @@
# increment location address
if row_content.Location != "" and LOCATION_MODEL_SET.match(row_content.Location):
old_location = row_content.Location
- model = re.compile("%[IQM][XBWLD]?(.*\.|)")
+ model = re.compile(r"%[IQM][XBWLD]?(.*\.|)") prefix = model.match(old_location).group(0)
addr = int(re.split(model, old_location)[-1]) + 1
row_content.Location = prefix + text(addr)
--- a/dialogs/ArrayTypeDialog.py Tue Oct 09 11:43:39 2018 +0300
+++ b/dialogs/ArrayTypeDialog.py Tue Oct 09 11:56:45 2018 +0300
@@ -34,7 +34,7 @@
# -------------------------------------------------------------------------------
-DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
+DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$") # -------------------------------------------------------------------------------
--- a/dialogs/DurationEditorDialog.py Tue Oct 09 11:43:39 2018 +0300
+++ b/dialogs/DurationEditorDialog.py Tue Oct 09 11:56:45 2018 +0300
@@ -41,7 +41,7 @@
-IEC_TIME_MODEL = re.compile("(?:T|TIME)#(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?$" % {"float": "[0-9]+(?:\.[0-9]+)?"})
+IEC_TIME_MODEL = re.compile(r"(?:T|TIME)#(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?$" % {"float": r"[0-9]+(?:\.[0-9]+)?"}) # -------------------------------------------------------------------------------
--- a/dialogs/ForceVariableDialog.py Tue Oct 09 11:43:39 2018 +0300
+++ b/dialogs/ForceVariableDialog.py Tue Oct 09 11:56:45 2018 +0300
@@ -70,10 +70,10 @@
-IEC_TIME_MODEL = re.compile("(?:(?:T|TIME)#)?(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?$" % {"float": "[0-9]+(?:\.[0-9]+)?"})
-IEC_DATE_MODEL = re.compile("(?:(?:D|DATE)#)?([0-9]{4})-([0-9]{2})-([0-9]{2})$")
-IEC_DATETIME_MODEL = re.compile("(?:(?:DT|DATE_AND_TIME)#)?([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]+)?)$")
-IEC_TIMEOFDAY_MODEL = re.compile("(?:(?:TOD|TIME_OF_DAY)#)?([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]+)?)$")
+IEC_TIME_MODEL = re.compile(r"(?:(?:T|TIME)#)?(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?$" % {"float": r"[0-9]+(?:\.[0-9]+)?"}) +IEC_DATE_MODEL = re.compile(r"(?:(?:D|DATE)#)?([0-9]{4})-([0-9]{2})-([0-9]{2})$") +IEC_DATETIME_MODEL = re.compile(r"(?:(?:DT|DATE_AND_TIME)#)?([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]+)?)$") +IEC_TIMEOFDAY_MODEL = re.compile(r"(?:(?:TOD|TIME_OF_DAY)#)?([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]+)?)$") --- a/editors/DataTypeEditor.py Tue Oct 09 11:43:39 2018 +0300
+++ b/editors/DataTypeEditor.py Tue Oct 09 11:56:45 2018 +0300
@@ -44,7 +44,7 @@
# -------------------------------------------------------------------------------
-DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
+DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$") def AppendMenu(parent, help, id, kind, text):
--- a/etherlab/ConfigEditor.py Tue Oct 09 11:43:39 2018 +0300
+++ b/etherlab/ConfigEditor.py Tue Oct 09 11:56:45 2018 +0300
@@ -72,7 +72,7 @@
ETHERCAT_INDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,4})$")
ETHERCAT_SUBINDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,2})$")
-LOCATION_MODEL = re.compile("(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$")
+LOCATION_MODEL = re.compile(r"(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$") class NodeVariablesSizer(wx.FlexGridSizer):
--- a/i18n/mki18n.py Tue Oct 09 11:43:39 2018 +0300
+++ b/i18n/mki18n.py Tue Oct 09 11:56:45 2018 +0300
@@ -214,10 +214,10 @@
verbosePrint(verbose, cmd)
- XSD_STRING_MODEL = re.compile("<xsd\:(?:element|attribute) name=\"([^\"]*)\"[^\>]*\>")
+ XSD_STRING_MODEL = re.compile(r"<xsd\:(?:element|attribute) name=\"([^\"]*)\"[^\>]*\>") processCustomFiles(filelist, fileout, XSD_STRING_MODEL, 'Extra XSD strings')
- XML_TC6_STRING_MODEL = re.compile("<documentation>\s*<xhtml\:p><!\[CDATA\[([^\]]*)\]\]></xhtml\:p>\s*</documentation>", re.MULTILINE | re.DOTALL)
+ XML_TC6_STRING_MODEL = re.compile(r"<documentation>\s*<xhtml\:p><!\[CDATA\[([^\]]*)\]\]></xhtml\:p>\s*</documentation>", re.MULTILINE | re.DOTALL) processCustomFiles(filelist, fileout, XML_TC6_STRING_MODEL, 'Extra TC6 documentation strings')
--- a/plcopen/plcopen.py Tue Oct 09 11:43:39 2018 +0300
+++ b/plcopen/plcopen.py Tue Oct 09 11:56:45 2018 +0300
@@ -79,7 +79,7 @@
-FILTER_ADDRESS_MODEL = "(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)"
+FILTER_ADDRESS_MODEL = r"(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)" def update_address(address, address_model, new_leading):
@@ -231,8 +231,8 @@
"http://www.plcopen.org/xml/tc6.xsd",
"http://www.plcopen.org/xml/tc6_0201")
- (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
- (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
+ (re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["), + (re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]: project_xml = cre.sub(repl, project_xml)
@@ -2876,7 +2876,7 @@
cls = PLCOpenParser.GetElementClass("arrayValue", "value")
- arrayValue_model = re.compile("([0-9]+)\((.*)\)$")
+ arrayValue_model = re.compile(r"([0-9]+)\((.*)\)$") _updateArrayValueValueClass(cls)
# ----------------------------------------------------------------------
--- a/py_ext/PythonFileCTNMixin.py Tue Oct 09 11:43:39 2018 +0300
+++ b/py_ext/PythonFileCTNMixin.py Tue Oct 09 11:56:45 2018 +0300
@@ -63,8 +63,8 @@
'xmlns="http://www.w3.org/2001/XMLSchema"',
'xmlns:xhtml="http://www.w3.org/1999/xhtml"')
- (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
- (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
+ (re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["), + (re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]: pythonfile_xml = cre.sub(repl, pythonfile_xml)
--- a/svgui/pyjs/build.py Tue Oct 09 11:43:39 2018 +0300
+++ b/svgui/pyjs/build.py Tue Oct 09 11:56:45 2018 +0300
@@ -45,7 +45,7 @@
# .cache.html files produces look like this
-CACHE_HTML_PAT = re.compile('^[a-z]*.[0-9a-f]{32}\.cache\.html$')
+CACHE_HTML_PAT = re.compile(r'^[a-z]*.[0-9a-f]{32}\.cache\.html$') # ok these are the three "default" library directories, containing
# the builtins (str, List, Dict, ord, round, len, range etc.)
--- a/svgui/pyjs/lib/pyjslib.py Tue Oct 09 11:43:39 2018 +0300
+++ b/svgui/pyjs/lib/pyjslib.py Tue Oct 09 11:56:45 2018 +0300
@@ -285,7 +285,7 @@
return "AttributeError: %s of %s" % (self.args[1], self.args[0])
pyjslib.StopIteration = function () { };
pyjslib.StopIteration.prototype = new Error();
pyjslib.StopIteration.name = 'StopIteration';
--- a/targets/toolchain_gcc.py Tue Oct 09 11:43:39 2018 +0300
+++ b/targets/toolchain_gcc.py Tue Oct 09 11:56:45 2018 +0300
@@ -33,7 +33,7 @@
from util.ProcessLogger import ProcessLogger
-includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*')
+includes_re = re.compile(r'\s*#include\s*["<]([^">]*)[">].*') class toolchain_gcc(object):
--- a/targets/toolchain_makefile.py Tue Oct 09 11:43:39 2018 +0300
+++ b/targets/toolchain_makefile.py Tue Oct 09 11:56:45 2018 +0300
@@ -32,7 +32,7 @@
from util.ProcessLogger import ProcessLogger
-includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*')
+includes_re = re.compile(r'\s*#include\s*["<]([^">]*)[">].*') class toolchain_makefile(object):
--- a/xmlclass/xmlclass.py Tue Oct 09 11:43:39 2018 +0300
+++ b/xmlclass/xmlclass.py Tue Oct 09 11:56:45 2018 +0300
@@ -61,24 +61,24 @@
# Regular expression models for checking all kind of
# string values defined in XML standard
-Name_model = re.compile('([a-zA-Z_\:][\w\.\-\:]*)$')
-Names_model = re.compile('([a-zA-Z_\:][\w\.\-\:]*(?: [a-zA-Z_\:][\w\.\-\:]*)*)$')
-NMToken_model = re.compile('([\w\.\-\:]*)$')
-NMTokens_model = re.compile('([\w\.\-\:]*(?: [\w\.\-\:]*)*)$')
-QName_model = re.compile('((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)$')
-QNames_model = re.compile('((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*(?: (?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)*)$')
-NCName_model = re.compile('([a-zA-Z_][\w]*)$')
-URI_model = re.compile('((?:htt(p|ps)://|/)?(?:[\w.-]*/?)*)$')
-LANGUAGE_model = re.compile('([a-zA-Z]{1,8}(?:-[a-zA-Z0-9]{1,8})*)$')
+Name_model = re.compile(r'([a-zA-Z_\:][\w\.\-\:]*)$') +Names_model = re.compile(r'([a-zA-Z_\:][\w\.\-\:]*(?: [a-zA-Z_\:][\w\.\-\:]*)*)$') +NMToken_model = re.compile(r'([\w\.\-\:]*)$') +NMTokens_model = re.compile(r'([\w\.\-\:]*(?: [\w\.\-\:]*)*)$') +QName_model = re.compile(r'((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)$') +QNames_model = re.compile(r'((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*(?: (?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)*)$') +NCName_model = re.compile(r'([a-zA-Z_][\w]*)$') +URI_model = re.compile(r'((?:htt(p|ps)://|/)?(?:[\w.-]*/?)*)$') +LANGUAGE_model = re.compile(r'([a-zA-Z]{1,8}(?:-[a-zA-Z0-9]{1,8})*)$') -ONLY_ANNOTATION = re.compile("((?:annotation )?)")
+ONLY_ANNOTATION = re.compile(r"((?:annotation )?)") Regular expression models for extracting dates and times from a string
-time_model = re.compile('([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)(?:Z)?$')
-date_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
-datetime_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
+time_model = re.compile(r'([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)(?:Z)?$') +date_model = re.compile(r'([0-9]{4})-([0-9]{2})-([0-9]{2})((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$') +datetime_model = re.compile(r'([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$') class xml_timezone(datetime.tzinfo):
@@ -1249,7 +1249,7 @@
if element["type"] == ANY:
- elements.append(ComputeMultiplicity("#text |#cdata-section |\w* ", infos))
+ elements.append(ComputeMultiplicity(r"#text |#cdata-section |\w* ", infos)) elif element["type"] == CHOICE:
for infos in element["choices"]:
@@ -1721,7 +1721,7 @@
-NAMESPACE_PATTERN = re.compile("xmlns(?:\:[^\=]*)?=\"[^\"]*\" ")
+NAMESPACE_PATTERN = re.compile(r"xmlns(?:\:[^\=]*)?=\"[^\"]*\" ") class DefaultElementClass(etree.ElementBase):