Make python Regex Strings raw to avoid py3.12 SyntaxError

This commit is contained in:
bgbsww
2024-09-26 18:12:20 -04:00
committed by Yorik van Havre
parent 37857a8dad
commit 94aad208bc
26 changed files with 75 additions and 75 deletions

View File

@@ -462,7 +462,7 @@ class bsplineTracker(Tracker):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n", "")
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = re.findall(r"point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:
@@ -540,7 +540,7 @@ class bezcurveTracker(Tracker):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n","")
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = re.findall(r"point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:
@@ -669,7 +669,7 @@ class arcTracker(Tracker):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n", "")
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = re.findall(r"point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:

View File

@@ -221,18 +221,18 @@ def deformat(text):
The deformatted string.
"""
# remove ACAD string formatation
# t = re.sub('{([^!}]([^}]|\n)*)}', '', text)
# t = re.sub(r'{([^!}]([^}]|\n)*)}', '', text)
# print("input text: ",text)
t = text.strip("{}")
t = re.sub("\\\\.*?;", "", t)
t = re.sub(r"\\\\.*?;", "", t)
# replace UTF codes by utf chars
sts = re.split("\\\\(U\\+....)", t)
t = u"".join(sts)
# replace degrees, diameters chars
t = re.sub('%%d', u'°', t)
t = re.sub('%%c', u'Ø', t)
t = re.sub('%%D', u'°', t)
t = re.sub('%%C', u'Ø', t)
t = re.sub(r'%%d', u'°', t)
t = re.sub(r'%%c', u'Ø', t)
t = re.sub(r'%%D', u'°', t)
t = re.sub(r'%%C', u'Ø', t)
# print("output text: ", t)
return t
@@ -3934,7 +3934,7 @@ def exportPage(page, filename):
f = pyopen(page.Template, "rb")
svgtemplate = f.read()
f.close()
editables = re.findall("freecad:editable=\"(.*?)\"", svgtemplate)
editables = re.findall(r"freecad:editable=\"(.*?)\"", svgtemplate)
values = page.EditableTexts
for i in range(len(editables)):
if len(values) > i:
@@ -3953,7 +3953,7 @@ def exportPage(page, filename):
blocks = ""
entities = ""
r12 = False
ver = re.findall("\\$ACADVER\n.*?\n(.*?)\n", template)
ver = re.findall(r"\\$ACADVER\n.*?\n(.*?)\n", template)
if ver:
# at the moment this is not used.
# TODO: if r12, do not print ellipses or splines
@@ -3969,7 +3969,7 @@ def exportPage(page, filename):
if entities:
template = template.replace("999\n$entities", entities[:-1])
c = dxfcounter()
pat = re.compile("(_handle_)")
pat = re.compile(r"(_handle_)")
template = pat.sub(c.incr, template)
f = pyopen(filename, "w")
f.write(template)

View File

@@ -1712,7 +1712,7 @@ def getContents(filename, tag, stringmode=False):
searchpat = '<' + tag + '.*?</' + tag + '>'
tags = re.findall(searchpat, contents)
for t in tags:
tagid = re.findall('id="(.*?)"', t)
tagid = re.findall(r'id="(.*?)"', t)
if tagid:
tagid = tagid[0]
else: