Make python Regex Strings raw to avoid py3.12 SyntaxError
This commit is contained in:
@@ -525,13 +525,13 @@ class BIM_Classification:
|
||||
currentItem.parent.children.append(currentItem)
|
||||
if "</Item>" in l:
|
||||
currentItem = currentItem.parent
|
||||
elif currentItem and re.findall("<ID>(.*?)</ID>", l):
|
||||
currentItem.ID = re.findall("<ID>(.*?)</ID>", l)[0]
|
||||
elif currentItem and re.findall("<Name>(.*?)</Name>", l):
|
||||
currentItem.Name = re.findall("<Name>(.*?)</Name>", l)[0]
|
||||
elif currentItem and re.findall(r"<ID>(.*?)</ID>", l):
|
||||
currentItem.ID = re.findall(r"<ID>(.*?)</ID>", l)[0]
|
||||
elif currentItem and re.findall(r"<Name>(.*?)</Name>", l):
|
||||
currentItem.Name = re.findall(r"<Name>(.*?)</Name>", l)[0]
|
||||
elif (
|
||||
currentItem
|
||||
and re.findall("<Description>(.*?)</Description>", l)
|
||||
and re.findall(r"<Description>(.*?)</Description>", l)
|
||||
and not currentItem.Name
|
||||
):
|
||||
currentItem.Name = re.findall(
|
||||
|
||||
@@ -779,8 +779,8 @@ class BIM_Library_TaskPanel:
|
||||
p = u.read()
|
||||
if sys.version_info.major >= 3:
|
||||
p = str(p)
|
||||
dirs = re.findall("<.*?octicon-file-directory.*?href.*?>(.*?)</a>", p)
|
||||
files = re.findall('<.*?octicon-file".*?href.*?>(.*?)</a>', p)
|
||||
dirs = re.findall(r"<.*?octicon-file-directory.*?href.*?>(.*?)</a>", p)
|
||||
files = re.findall(r'<.*?octicon-file".*?href.*?>(.*?)</a>', p)
|
||||
nfiles = []
|
||||
for f in files:
|
||||
for ft in self.getFilters():
|
||||
@@ -791,8 +791,8 @@ class BIM_Library_TaskPanel:
|
||||
for d in dirs:
|
||||
# <spans>
|
||||
if "</span" in d:
|
||||
d1 = re.findall("<span.*?>(.*?)<", d)
|
||||
d2 = re.findall("</span>(.*?)$", d)
|
||||
d1 = re.findall(r"<span.*?>(.*?)<", d)
|
||||
d2 = re.findall(r"</span>(.*?)$", d)
|
||||
if d1 and d2:
|
||||
d = d1[0] + "/" + d2[0]
|
||||
r = self.getOnlineContentsWEB(url + "/" + d.replace(" ", "%20"))
|
||||
|
||||
@@ -287,7 +287,7 @@ class BIM_Preflight_TaskPanel:
|
||||
label = test.replace("test", "label")
|
||||
tooltip = getattr(self.form, label).toolTip()
|
||||
tooltip = tooltip.replace("</p>", "</p>\n\n")
|
||||
tooltip = re.sub("<.*?>", "", tooltip) # strip html tags
|
||||
tooltip = re.sub(r"<.*?>", "", tooltip) # strip html tags
|
||||
return tooltip
|
||||
|
||||
def testAll(self):
|
||||
|
||||
@@ -689,7 +689,7 @@ class BIM_Setup:
|
||||
u.close()
|
||||
d = json.loads(r)
|
||||
l = d[-1]["body"]
|
||||
links = re.findall("http.*?zip", l)
|
||||
links = re.findall(r"http.*?zip", l)
|
||||
pyv = (
|
||||
"python-"
|
||||
+ str(sys.version_info.major)
|
||||
|
||||
@@ -141,16 +141,16 @@ class BIM_Tutorial:
|
||||
f.close()
|
||||
|
||||
# setup title and progress bar
|
||||
self.steps = len(re.findall("infotext", html)) - 1
|
||||
self.steps = len(re.findall(r"infotext", html)) - 1
|
||||
|
||||
# setup description texts and goals
|
||||
self.descriptions = [""] + re.findall(
|
||||
"<p><br /> </p><p><br /> </p> (.*?)<p><b>Tutorial step", html
|
||||
)
|
||||
self.goal1 = re.findall('goal1">(.*?)</div', html)
|
||||
self.goal2 = re.findall('goal2">(.*?)</div', html)
|
||||
self.test1 = re.findall('test1".*?>(.*?)</div', html)
|
||||
self.test2 = re.findall('test2".*?>(.*?)</div', html)
|
||||
self.goal1 = re.findall(r'goal1">(.*?)</div', html)
|
||||
self.goal2 = re.findall(r'goal2">(.*?)</div', html)
|
||||
self.test1 = re.findall(r'test1".*?>(.*?)</div', html)
|
||||
self.test2 = re.findall(r'test2".*?>(.*?)</div', html)
|
||||
|
||||
# fix mediawiki encodes
|
||||
self.test1 = [t.replace("<", "<").replace(">", ">") for t in self.test1]
|
||||
@@ -162,14 +162,14 @@ class BIM_Tutorial:
|
||||
)
|
||||
nd = []
|
||||
for descr in self.descriptions:
|
||||
imagepaths = re.findall('<img.*?src="(.*?)"', descr)
|
||||
imagepaths = re.findall(r'<img.*?src="(.*?)"', descr)
|
||||
if imagepaths:
|
||||
store = os.path.join(FreeCAD.getUserAppDataDir(), "BIM", "Tutorial")
|
||||
if not os.path.exists(store):
|
||||
os.makedirs(store)
|
||||
for path in imagepaths:
|
||||
# name = re.findall("[\\w.-]+\\.(?i)(?:jpg|png|gif|bmp)",path)
|
||||
name = re.findall("(?i)[\\w.-]+\\.(?:jpg|png|gif|bmp)", path)
|
||||
# name = re.findall(r"[\\w.-]+\\.(?i)(?:jpg|png|gif|bmp)",path)
|
||||
name = re.findall(r"(?i)[\\w.-]+\\.(?:jpg|png|gif|bmp)", path)
|
||||
if name:
|
||||
name = name[-1]
|
||||
storename = os.path.join(store, name)
|
||||
|
||||
Reference in New Issue
Block a user