From 39bee92bea3142c122befb52a1a03dae44c31d9a Mon Sep 17 00:00:00 2001 From: Kevin Martin Date: Thu, 1 Feb 2024 10:50:52 -0500 Subject: [PATCH] Replace deprecated escapes with valid ones --- src/Mod/Draft/draftguitools/gui_trackers.py | 6 +++--- src/Mod/Draft/importDXF.py | 6 +++--- src/Mod/Draft/importSVG.py | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_trackers.py b/src/Mod/Draft/draftguitools/gui_trackers.py index c59c2f107080..2789ada48885 100644 --- a/src/Mod/Draft/draftguitools/gui_trackers.py +++ b/src/Mod/Draft/draftguitools/gui_trackers.py @@ -445,7 +445,7 @@ def recompute(self): except Exception: # workaround for pivy SoInput.setBuffer() bug buf = buf.replace("\n", "") - pts = re.findall("point \[(.*?)\]", buf)[0] + pts = re.findall("point \\[(.*?)\\]", buf)[0] pts = pts.split(",") pc = [] for p in pts: @@ -523,7 +523,7 @@ def recompute(self): except Exception: # workaround for pivy SoInput.setBuffer() bug buf = buf.replace("\n","") - pts = re.findall("point \[(.*?)\]", buf)[0] + pts = re.findall("point \\[(.*?)\\]", buf)[0] pts = pts.split(",") pc = [] for p in pts: @@ -652,7 +652,7 @@ def recompute(self): except Exception: # workaround for pivy SoInput.setBuffer() bug buf = buf.replace("\n", "") - pts = re.findall("point \[(.*?)\]", buf)[0] + pts = re.findall("point \\[(.*?)\\]", buf)[0] pts = pts.split(",") pc = [] for p in pts: diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 9fbd34cb4916..3c159f53352b 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -223,9 +223,9 @@ def deformat(text): # t = re.sub('{([^!}]([^}]|\n)*)}', '', text) # print("input text: ",text) t = text.strip("{}") - t = re.sub("\\\.*?;", "", t) + t = re.sub("\\\\.*?;", "", t) # replace UTF codes by utf chars - sts = re.split("\\\\(U\+....)", t) + sts = re.split("\\\\(U\\+....)", t) t = u"".join(sts) # replace degrees, diameters chars t = re.sub('%%d', u'°', t) @@ -3925,7 +3925,7 @@ def exportPage(page, filename): blocks = "" entities = "" r12 = False - ver = re.findall("\$ACADVER\n.*?\n(.*?)\n", template) + ver = re.findall("\\$ACADVER\n.*?\n(.*?)\n", template) if ver: # at the moment this is not used. # TODO: if r12, do not print ellipses or splines diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 98e9650ee80c..155e9af7357a 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -415,7 +415,7 @@ def getsize(length, mode='discard', base=1): } # Extract a number from a string like '+56215.14565E+6mm' - _num = '([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)' + _num = '([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)' _unit = '(px|pt|pc|mm|cm|in|em|ex|%)?' _full_num = _num + _unit number, exponent, unit = re.findall(_full_num, length)[0] @@ -725,7 +725,7 @@ def startElement(self, name, attrs): if 'inkscape:version' in data: inks_doc_name = attrs.getValue('sodipodi:docname') inks_full_ver = attrs.getValue('inkscape:version') - inks_ver_pars = re.search("\d+\.\d+", inks_full_ver) + inks_ver_pars = re.search("\\d+\\.\\d+", inks_full_ver) if inks_ver_pars is not None: inks_ver_f = float(inks_ver_pars.group(0)) else: @@ -928,10 +928,10 @@ def startElement(self, name, attrs): _op = '([mMlLhHvVaAcCqQsStTzZ])' _op2 = '([^mMlLhHvVaAcCqQsStTzZ]*)' - _command = '\s*?' + _op + '\s*?' + _op2 + '\s*?' + _command = '\\s*?' + _op + '\\s*?' + _op2 + '\\s*?' pathcommandsre = re.compile(_command, re.DOTALL) - _num = '[-+]?[0-9]*\.?[0-9]+' + _num = '[-+]?[0-9]*\\.?[0-9]+' _exp = '([eE][-+]?[0-9]+)?' _point = '(' + _num + _exp + ')' pointsre = re.compile(_point, re.DOTALL) @@ -1613,8 +1613,8 @@ def getMatrix(self, tr): The translated matrix. """ _op = '(matrix|translate|scale|rotate|skewX|skewY)' - _val = '\((.*?)\)' - _transf = _op + '\s*?' + _val + _val = '\\((.*?)\\)' + _transf = _op + '\\s*?' + _val transformre = re.compile(_transf, re.DOTALL) m = FreeCAD.Matrix() for transformation, arguments in transformre.findall(tr):