--- a/src/Mod/Arch/ArchAxis.py +++ b/src/Mod/Arch/ArchAxis.py @@ -451,7 +451,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: --- a/src/Mod/Arch/ArchRebar.py +++ b/src/Mod/Arch/ArchRebar.py @@ -556,7 +556,7 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent): import re self.centerline = coin.SoSeparator() comp = Part.makeCompound(obj.Proxy.wires) - pts = re.findall("point \[(.*?)\]",comp.writeInventor().replace("\n","")) + pts = re.findall(r"point \[(.*?)\]",comp.writeInventor().replace("\n","")) pts = [p.split(",") for p in pts] for pt in pts: ps = coin.SoSeparator() --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -748,7 +748,7 @@ def getCoinSVG(cutplane,objs,cameradata=None,linewidth=0.2,singleface=False,face wp.alignToPointAndAxis_SVG(Vector(0,0,0),cutplane.normalAt(0,0),0) p = wp.getLocalCoords(markervec) orlength = FreeCAD.Vector(p.x,p.y,0).Length - marker = re.findall("",svg) + marker = re.findall(r'',svg) if marker: marker = marker[0].split("\"") x1 = float(marker[1]) @@ -764,7 +764,7 @@ 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("","",svg,count=1) + svg = re.sub(r'',"",svg,count=1) # remove background rectangle svg = re.sub("","",svg,count=1,flags=re.MULTILINE|re.DOTALL) @@ -792,9 +792,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,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,flags=re.MULTILINE|re.DOTALL) + svg = re.sub(r"<\/svg>","",svg,flags=re.MULTILINE|re.DOTALL) ISRENDERING = False --- a/src/Mod/Arch/ArchSite.py +++ b/src/Mod/Arch/ArchSite.py @@ -92,7 +92,7 @@ def toNode(shape): from pivy import coin buf = shape.writeInventor(2,0.01) buf = buf.replace("\n","") - buf = re.findall("point \[(.*?)\]",buf) + buf = re.findall(r"point \[(.*?)\]",buf) pts = [] for c in buf: pts.extend(c.split(",")) --- a/src/Mod/Arch/importIFClegacy.py +++ b/src/Mod/Arch/importIFClegacy.py @@ -39,7 +39,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]?$") PRECISION = 4 # rounding value, in number of digits APPLYFIX = True # if true, the ifcopenshell bug-fixing function is applied when saving files # end config @@ -1440,9 +1440,9 @@ class IfcSchema: entity = {} raw_entity_str = m.groups()[0] - entity["name"] = re.search("(.*?)[;|\s]", raw_entity_str).groups()[0].upper() + entity["name"] = re.search(r"(.*?)[;|\s]", raw_entity_str).groups()[0].upper() - subtypeofmatch = re.search(".*SUBTYPE OF \((.*?)\);", raw_entity_str) + subtypeofmatch = re.search(r".*SUBTYPE OF \((.*?)\);", raw_entity_str) entity["supertype"] = subtypeofmatch.groups()[0].upper() if subtypeofmatch else None # find the shortest string matched from the end of the entity type header to the --- a/src/Mod/Draft/draftguitools/gui_trackers.py +++ b/src/Mod/Draft/draftguitools/gui_trackers.py @@ -423,7 +423,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: @@ -501,7 +501,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: @@ -636,7 +636,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: --- a/src/Mod/Draft/importAirfoilDAT.py +++ b/src/Mod/Draft/importAirfoilDAT.py @@ -4,12 +4,6 @@ # \brief Airfoil (.dat) file importer # # This module provides support for importing airfoil .dat files -'''@package importAirfoilDAT -\ingroup DRAFT -\brief Airfoil (.dat) file importer - -This module provides support for importing airfoil .dat files. -''' # Check code with # flake8 --ignore=E226,E266,E401,W503 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -233,9 +233,9 @@ def deformat(text): # t = re.sub('{([^!}]([^}]|\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) + sts = re.split(r"\\(U\+....)", t) t = u"".join(sts) # replace degrees, diameters chars t = re.sub('%%d', u'°', t) @@ -3863,7 +3863,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 --- a/src/Mod/Draft/importOCA.py +++ b/src/Mod/Draft/importOCA.py @@ -2,17 +2,14 @@ ## @package importOCA # \ingroup DRAFT # \brief OCA (Open CAD Format) file importer & exporter -'''@package importOCA -\ingroup DRAFT -\brief OCA (Open CAD Format) file importer & exporter +# +# This module provides support for importing from and exporting to +# the OCA format or GCAD format from GCAD3D (http://www.gcad3d.org/). +# See: https://groups.google.com/forum/#!forum/open_cad_format +# +# As of 2019 this file format is practically obsolete, and this module is not +# maintained. -This module provides support for importing from and exporting to -the OCA format or GCAD format from GCAD3D (http://www.gcad3d.org/). -See: https://groups.google.com/forum/#!forum/open_cad_format - -As of 2019 this file format is practically obsolete, and this module is not -maintained. -''' # Check code with # flake8 --ignore=E226,E266,E401,W503 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -73,8 +73,7 @@ else: draftui = None # Save the native open function to avoid collisions -if open.__module__ in ['__builtin__', 'io']: - pythonopen = open +pythonopen = open svgcolors = { 'Pink': (255, 192, 203), @@ -413,8 +412,8 @@ 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]+)?)' - _unit = '(px|pt|pc|mm|cm|in|em|ex|%)?' + _num = r"([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)" + _unit = r"(px|pt|pc|mm|cm|in|em|ex|%)?" _full_num = _num + _unit number, exponent, unit = re.findall(_full_num, length)[0] if mode == 'discard': @@ -729,7 +728,7 @@ class svgHandler(xml.sax.ContentHandler): 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(r"\d+\.\d+", inks_full_ver) if inks_ver_pars is not None: inks_ver_f = float(inks_ver_pars.group(0)) else: @@ -930,13 +929,13 @@ class svgHandler(xml.sax.ContentHandler): self.lastdim = obj data['d'] = [] - _op = '([mMlLhHvVaAcCqQsStTzZ])' - _op2 = '([^mMlLhHvVaAcCqQsStTzZ]*)' - _command = '\s*?' + _op + '\s*?' + _op2 + '\s*?' + _op = r"([mMlLhHvVaAcCqQsStTzZ])" + _op2 = r"([^mMlLhHvVaAcCqQsStTzZ]*)" + _command = r"\s*?" + _op + r"\s*?" + _op2 + r"\s*?" pathcommandsre = re.compile(_command, re.DOTALL) - _num = '[-+]?[0-9]*\.?[0-9]+' - _exp = '([eE][-+]?[0-9]+)?' + _num = r"[-+]?[0-9]*\.?[0-9]+" + _exp = r"([eE][-+]?[0-9]+)?" _point = '(' + _num + _exp + ')' pointsre = re.compile(_point, re.DOTALL) _commands = pathcommandsre.findall(' '.join(data['d'])) @@ -1616,9 +1615,9 @@ class svgHandler(xml.sax.ContentHandler): Base::Matrix4D The translated matrix. """ - _op = '(matrix|translate|scale|rotate|skewX|skewY)' - _val = '\((.*?)\)' - _transf = _op + '\s*?' + _val + _op = r"(matrix|translate|scale|rotate|skewX|skewY)" + _val = r"\((.*?)\)" + _transf = _op + r"\s*?" + _val transformre = re.compile(_transf, re.DOTALL) m = FreeCAD.Matrix() for transformation, arguments in transformre.findall(tr): --- a/src/Mod/Path/Path/Post/scripts/gcode_pre.py +++ b/src/Mod/Path/Path/Post/scripts/gcode_pre.py @@ -191,10 +191,10 @@ def _identifygcodeByToolNumberList(filename): gfile.close() # Regular expression to match tool changes in the format 'M6 Tn' - p = re.compile("[mM]+?\s?0?6\s?T\d*\s") + p = re.compile(r"[mM]+?\s?0?6\s?T\d*\s") # split the gcode on tool changes - paths = re.split("([mM]+?\s?0?6\s?T\d*\s)", gcode) + paths = re.split(r"([mM]+?\s?0?6\s?T\d*\s)", gcode) # iterate the gcode sections and add customs for each toolnumber = 0 --- a/src/Mod/Path/PathTests/TestPathPost.py +++ b/src/Mod/Path/PathTests/TestPathPost.py @@ -352,7 +352,7 @@ class TestBuildPostList(unittest.TestCase): class TestOutputNameSubstitution(unittest.TestCase): - """ + r""" String substitution allows the following: %D ... directory of the active document %d ... name of the active document (with extension) --- a/src/Mod/Robot/KukaExporter.py +++ b/src/Mod/Robot/KukaExporter.py @@ -21,7 +21,7 @@ DECL FDAT FP4={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " "} DECL LDAT LCPDAT1={VEL 2.0,ACC 100.0,APO_DIST 100.0,APO_FAC 50.0,ORI_TYP #VAR} """ -HeaderSrc = """&ACCESS RVP +HeaderSrc = r"""&ACCESS RVP &REL 1 &PARAM TEMPLATE = C:\KRC\Roboter\Template\ExpertVorgabe &PARAM EDITMASK = *