Skip to content

Commit

Permalink
Replace deprecated escapes with valid ones
Browse files Browse the repository at this point in the history
  • Loading branch information
kpemartin committed Feb 2, 2024
1 parent 02ebb17 commit 39bee92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Mod/Draft/draftguitools/gui_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Draft/importDXF.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Draft/importSVG.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 39bee92

Please sign in to comment.