Make python Regex Strings raw to avoid py3.12 SyntaxError
This commit is contained in:
@@ -398,7 +398,7 @@ class _ViewProviderAxis:
|
||||
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 point in pts:
|
||||
|
||||
@@ -971,12 +971,12 @@ class ViewProviderBuildingPart:
|
||||
iv = self.Object.Shape.writeInventor()
|
||||
import re
|
||||
if colors:
|
||||
if len(re.findall("IndexedFaceSet",iv)) == len(obj.Shape.Faces):
|
||||
if len(re.findall(r"IndexedFaceSet",iv)) == len(obj.Shape.Faces):
|
||||
# convert colors to iv representations
|
||||
colors = ["Material { diffuseColor "+str(color[0])+" "+str(color[1])+" "+str(color[2])+"}\n IndexedFaceSet" for color in colors]
|
||||
# replace
|
||||
callback.v=iter(colors)
|
||||
iv = re.sub("IndexedFaceSet",callback,iv)
|
||||
iv = re.sub(r"IndexedFaceSet",callback,iv)
|
||||
else:
|
||||
print("Debug: IndexedFaceSet mismatch in",obj.Label)
|
||||
# save embedded file
|
||||
|
||||
@@ -450,7 +450,7 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
|
||||
import re
|
||||
self.centerline = coin.SoSeparator()
|
||||
comp = Part.makeCompound(obj.Proxy.wires)
|
||||
buf = re.findall("point \[(.*?)\]",comp.writeInventor().replace("\n",""))
|
||||
buf = re.findall(r"point \[(.*?)\]",comp.writeInventor().replace("\n",""))
|
||||
pts = [zip(*[iter( c.split() )]*3) for c in buf]
|
||||
for pt in pts:
|
||||
vlist = [ [float(v[0]),float(v[1]),float(v[2])] for v in pt ]
|
||||
|
||||
@@ -390,28 +390,28 @@ class ArchReference:
|
||||
for line in docf:
|
||||
line = line.decode("utf8")
|
||||
if "<Object name=" in line:
|
||||
n = re.findall('name=\"(.*?)\"',line)
|
||||
n = re.findall(r'name=\"(.*?)\"',line)
|
||||
if n:
|
||||
name = n[0]
|
||||
elif "<Property name=\"Label\"" in line:
|
||||
writemode = True
|
||||
elif writemode and "<String value=" in line:
|
||||
n = re.findall('value=\"(.*?)\"',line)
|
||||
n = re.findall(r'value=\"(.*?)\"',line)
|
||||
if n:
|
||||
label = n[0]
|
||||
writemode = False
|
||||
elif "<Property name=\"Shape\" type=\"Part::PropertyPartShape\"" in line:
|
||||
writemode = True
|
||||
elif writemode and "<Part file=" in line:
|
||||
n = re.findall('file=\"(.*?)\"',line)
|
||||
n = re.findall(r'file=\"(.*?)\"',line)
|
||||
if n:
|
||||
part = n[0]
|
||||
writemode = False
|
||||
elif "<Property name=\"MaterialsTable\" type=\"App::PropertyMap\"" in line:
|
||||
writemode = True
|
||||
elif writemode and "<Item key=" in line:
|
||||
n = re.findall('key=\"(.*?)\"',line)
|
||||
v = re.findall('value=\"(.*?)\"',line)
|
||||
n = re.findall(r'key=\"(.*?)\"',line)
|
||||
v = re.findall(r'value=\"(.*?)\"',line)
|
||||
if n and v:
|
||||
materials[n[0]] = v[0]
|
||||
elif writemode and "</Map>" in line:
|
||||
@@ -469,7 +469,7 @@ class ArchReference:
|
||||
writemode1 = False
|
||||
writemode2 = True
|
||||
elif writemode2 and ("<ColorList file=" in line):
|
||||
n = re.findall('file=\"(.*?)\"',line)
|
||||
n = re.findall(r'file=\"(.*?)\"',line)
|
||||
if n:
|
||||
colorfile = n[0]
|
||||
break
|
||||
@@ -808,7 +808,7 @@ class ViewProviderArchReference:
|
||||
writemode1 = False
|
||||
writemode2 = True
|
||||
elif writemode2 and ("<FileIncluded file=" in line):
|
||||
n = re.findall('file=\"(.*?)\"',line)
|
||||
n = re.findall(r'file=\"(.*?)\"',line)
|
||||
if n:
|
||||
ivfile = n[0]
|
||||
break
|
||||
|
||||
@@ -734,7 +734,7 @@ def getCoinSVG(cutplane,objs,cameradata=None,linewidth=0.2,singleface=False,face
|
||||
wp.align_to_point_and_axis_svg(Vector(0,0,0),cutplane.normalAt(0,0),0)
|
||||
p = wp.get_local_coords(markervec)
|
||||
orlength = FreeCAD.Vector(p.x,p.y,0).Length
|
||||
marker = re.findall("<line x1=.*?stroke=\"\#ffffff\".*?\/>",svg)
|
||||
marker = re.findall(r"<line x1=.*?stroke=\"\#ffffff\".*?\/>",svg)
|
||||
if marker:
|
||||
marker = marker[0].split("\"")
|
||||
x1 = float(marker[1])
|
||||
@@ -750,21 +750,21 @@ def getCoinSVG(cutplane,objs,cameradata=None,linewidth=0.2,singleface=False,face
|
||||
scaledp1 = FreeCAD.Vector(p1.x*factor,p1.y*factor,0)
|
||||
trans = orig.sub(scaledp1)
|
||||
# remove marker
|
||||
svg = re.sub("<line x1=.*?stroke=\"\#ffffff\".*?\/>","",svg,count=1)
|
||||
svg = re.sub(r"<line x1=.*?stroke=\"\#ffffff\".*?\/>","",svg,count=1)
|
||||
|
||||
# remove background rectangle
|
||||
svg = re.sub("<path.*?>","",svg,count=1,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub(r"<path.*?>","",svg,count=1,flags=re.MULTILINE|re.DOTALL)
|
||||
|
||||
# set face color to white
|
||||
if facecolor:
|
||||
res = re.findall("fill:(.*?); stroke:(.*?);",svg)
|
||||
res = re.findall(r"fill:(.*?); stroke:(.*?);",svg)
|
||||
pairs = []
|
||||
for pair in res:
|
||||
if (pair not in pairs) and (pair[0] == pair[1]) and(pair[0] not in ["#0a0a0a"]):
|
||||
# coin seems to be rendering a lot of lines as thin triangles with the #0a0a0a color...
|
||||
pairs.append(pair)
|
||||
for pair in pairs:
|
||||
svg = re.sub("fill:"+pair[0]+"; stroke:"+pair[1]+";","fill:"+facecolor+"; stroke:"+facecolor+";",svg)
|
||||
svg = re.sub(r"fill:"+pair[0]+"; stroke:"+pair[1]+";","fill:"+facecolor+"; stroke:"+facecolor+";",svg)
|
||||
|
||||
# embed everything in a scale group and scale the viewport
|
||||
if factor:
|
||||
@@ -778,9 +778,9 @@ def getCoinSVG(cutplane,objs,cameradata=None,linewidth=0.2,singleface=False,face
|
||||
QtCore.QTimer.singleShot(1,lambda: closeViewer(view_window_name))
|
||||
|
||||
# strip svg tags (needed for TD Arch view)
|
||||
svg = re.sub("<\?xml.*?>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub("<svg.*?>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub("<\/svg>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub(r"<\?xml.*?>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub(r"<svg.*?>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
svg = re.sub(r"<\/svg>","",svg,flags=re.MULTILINE|re.DOTALL)
|
||||
|
||||
ISRENDERING = False
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ def toNode(shape):
|
||||
|
||||
from pivy import coin
|
||||
buf = shape.writeInventor(2,0.01).replace("\n","")
|
||||
buf = re.findall("point \[(.*?)\]",buf)
|
||||
buf = re.findall(r"point \[(.*?)\]",buf)
|
||||
pts = []
|
||||
for c in buf:
|
||||
pts.extend(zip(*[iter( c.split() )]*3) )
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -41,7 +41,7 @@ SCHEMA = "http://www.steptools.com/support/stdev_docs/ifcbim/ifc4.exp" # only fo
|
||||
MAKETEMPFILES = False # if True, shapes are passed from ifcopenshell to freecad through temp files
|
||||
DEBUG = True # this is only for the python console, this value is overridden when importing through the GUI
|
||||
SKIP = ["IfcBuildingElementProxy","IfcFlowTerminal","IfcFurnishingElement"] # default. overwritten by the GUI options
|
||||
IFCLINE_RE = re.compile("#(\d+)[ ]?=[ ]?(.*?)\((.*)\);[\\r]?$")
|
||||
IFCLINE_RE = re.compile(r"#(\d+)[ ]?=[ ]?(.*?)\((.*)\);[\\r]?$")
|
||||
APPLYFIX = True # if true, the ifcopenshell bug-fixing function is applied when saving files
|
||||
# end config
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ def show_psets(obj):
|
||||
ptype, value = pvalue.split("(", 1)
|
||||
value = value.strip(")")
|
||||
value = value.strip("'")
|
||||
pname = re.sub("[^0-9a-zA-Z]+", "", pname)
|
||||
pname = re.sub(r"[^0-9a-zA-Z]+", "", pname)
|
||||
if pname[0].isdigit():
|
||||
pname = "_" + pname
|
||||
ttip = (
|
||||
|
||||
@@ -37,7 +37,7 @@ u = urlopen(
|
||||
)
|
||||
p = u.read().decode('utf-8')
|
||||
u.close()
|
||||
psets = re.findall(">Pset_(.*?)</a>", p)
|
||||
psets = re.findall(r">Pset_(.*?)</a>", p)
|
||||
|
||||
# retrieve xml data from each Pset type
|
||||
psetdefs = ""
|
||||
|
||||
Reference in New Issue
Block a user