From fdca2d49f7af718cd91a6ef1bcc8b60250b34f75 Mon Sep 17 00:00:00 2001 From: luzpaz Date: Wed, 19 Apr 2023 03:40:16 -0400 Subject: [PATCH] Arch: lint bad indentation, superfluous formatting (#9310) --- src/Mod/Arch/ArchAxisSystem.py | 2 +- src/Mod/Arch/ArchCommands.py | 58 ++++++++++++------------ src/Mod/Arch/ArchComponent.py | 38 ++++++++-------- src/Mod/Arch/ArchFence.py | 2 +- src/Mod/Arch/ArchSite.py | 2 +- src/Mod/Arch/ArchSpace.py | 16 +++---- src/Mod/Arch/ArchVRM.py | 1 - src/Mod/Arch/ArchWall.py | 8 ++-- src/Mod/Arch/ArchWindow.py | 6 +-- src/Mod/Arch/OfflineRenderingUtils.py | 2 +- src/Mod/Arch/exportIFC.py | 4 +- src/Mod/Arch/exportIFCStructuralTools.py | 6 +-- src/Mod/Arch/ifc_objects.py | 4 +- src/Mod/Arch/importGBXML.py | 4 -- src/Mod/Arch/importIFC.py | 4 +- src/Mod/Arch/importOBJ.py | 16 +++---- 16 files changed, 84 insertions(+), 89 deletions(-) diff --git a/src/Mod/Arch/ArchAxisSystem.py b/src/Mod/Arch/ArchAxisSystem.py index 523cae250d..7c425d681f 100644 --- a/src/Mod/Arch/ArchAxisSystem.py +++ b/src/Mod/Arch/ArchAxisSystem.py @@ -342,7 +342,7 @@ class AxisSystemTaskPanel: if self.obj: for o in FreeCADGui.Selection.getSelection(): - if (not(o in self.obj.Axes)) and (o != self.obj): + if not(o in self.obj.Axes) and (o != self.obj): g = self.obj.Axes g.append(o) self.obj.Axes = g diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 433a6331fe..d0ce15269d 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -178,33 +178,33 @@ def removeComponents(objectsList,host=None): else: for o in objectsList: if o.InList: - h = o.InList[0] - tp = Draft.getType(h) - if tp in ["Floor","Building","Site","BuildingPart"]: - c = h.Group - if o in c: - c.remove(o) - h.Group = c - o.ViewObject.show() - elif tp in ["Wall","Structure","Precast"]: - a = h.Additions - s = h.Subtractions - if o in a: - a.remove(o) - h.Additions = a - o.ViewObject.show() - elif o in s: - s.remove(o) - h.Subtractions = s - o.ViewObject.show() - elif o == s.Base: - s.Base = None - o.ViewObject.show() - elif tp in ["SectionPlane"]: - a = h.Objects - if o in a: - a.remove(o) - h.Objects = a + h = o.InList[0] + tp = Draft.getType(h) + if tp in ["Floor","Building","Site","BuildingPart"]: + c = h.Group + if o in c: + c.remove(o) + h.Group = c + o.ViewObject.show() + elif tp in ["Wall","Structure","Precast"]: + a = h.Additions + s = h.Subtractions + if o in a: + a.remove(o) + h.Additions = a + o.ViewObject.show() + elif o in s: + s.remove(o) + h.Subtractions = s + o.ViewObject.show() + elif o == s.Base: + s.Base = None + o.ViewObject.show() + elif tp in ["SectionPlane"]: + a = h.Objects + if o in a: + a.remove(o) + h.Objects = a def makeComponent(baseobj=None,name="Component",delete=False): '''makeComponent([baseobj]): creates an undefined, non-parametric Arch @@ -638,7 +638,7 @@ def mergeCells(objectslist): return None typ = Draft.getType(objectslist[0]) if not(typ in ["Cell","Floor","Building","Site"]): - return None + return None for o in objectslist: if Draft.getType(o) != typ: return None @@ -1102,7 +1102,7 @@ class SurveyTaskPanel: import csv rows = self.tree.topLevelItemCount() if rows: - filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)"); + filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)") if filename: with open(filename[0].encode("utf8"), "w") as csvfile: csvfile = csv.writer(csvfile,delimiter="\t") diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 26c4d5d596..32987a0297 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -208,9 +208,9 @@ class Component(ArchIFC.IfcProduct): if not "Material" in pl: obj.addProperty("App::PropertyLink","Material","Component",QT_TRANSLATE_NOOP("App::Property","A material for this object")) if "BaseMaterial" in pl: - obj.Material = obj.BaseMaterial - obj.removeProperty("BaseMaterial") - FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" BaseMaterial property to Material\n") + obj.Material = obj.BaseMaterial + obj.removeProperty("BaseMaterial") + FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" BaseMaterial property to Material\n") if not "MoveBase" in pl: obj.addProperty("App::PropertyBool","MoveBase","Component",QT_TRANSLATE_NOOP("App::Property","Specifies if moving this object moves its base instead")) obj.MoveBase = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("MoveBase",False) @@ -809,18 +809,18 @@ class Component(ArchIFC.IfcProduct): if o.Shape: if not o.Shape.isNull(): if o.Shape.Solids and base.Solids: - ## TODO use Part.Shape() instead? - s = o.Shape.copy() - if placement: - # see https://forum.freecadweb.org/viewtopic.php?p=579754#p579754 - s.Placement = placement.multiply(s.Placement) - try: - if len(base.Solids) > 1: - base = Part.makeCompound([sol.cut(s) for sol in base.Solids]) - else: - base = base.cut(s) - except Part.OCCError: - print("Arch: unable to cut object ",o.Name, " from ", obj.Name) + ## TODO use Part.Shape() instead? + s = o.Shape.copy() + if placement: + # see https://forum.freecadweb.org/viewtopic.php?p=579754#p579754 + s.Placement = placement.multiply(s.Placement) + try: + if len(base.Solids) > 1: + base = Part.makeCompound([sol.cut(s) for sol in base.Solids]) + else: + base = base.cut(s) + except Part.OCCError: + print("Arch: unable to cut object ",o.Name, " from ", obj.Name) return base def spread(self,obj,shape,placement=None): @@ -1204,10 +1204,10 @@ class ViewProviderComponent: if obj.ViewObject.ShapeColor != c: obj.ViewObject.ShapeColor = c if 'Transparency' in obj.Material.Material: - t = int(obj.Material.Material['Transparency']) - if obj.ViewObject: - if obj.ViewObject.Transparency != t: - obj.ViewObject.Transparency = t + t = int(obj.Material.Material['Transparency']) + if obj.ViewObject: + if obj.ViewObject.Transparency != t: + obj.ViewObject.Transparency = t elif prop == "Shape": if obj.Base: if obj.Base.isDerivedFrom("Part::Compound"): diff --git a/src/Mod/Arch/ArchFence.py b/src/Mod/Arch/ArchFence.py index 25c90ca1bc..94b0fd045c 100644 --- a/src/Mod/Arch/ArchFence.py +++ b/src/Mod/Arch/ArchFence.py @@ -83,7 +83,7 @@ class _Fence(ArchComponent.Component): def __getstate__(self): if hasattr(self, 'sectionFaceNumbers'): - return (self.sectionFaceNumbers) + return self.sectionFaceNumbers return None diff --git a/src/Mod/Arch/ArchSite.py b/src/Mod/Arch/ArchSite.py index c5d4e4cba8..e1fb78195c 100644 --- a/src/Mod/Arch/ArchSite.py +++ b/src/Mod/Arch/ArchSite.py @@ -1066,7 +1066,7 @@ class _ViewProviderSite: """Updates the 'terrain' switches.""" if not hasattr(self, "terrain_switches"): - return + return idx = 0 if self.Object.Terrain is None else 1 for switch in self.terrain_switches: diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py index bf5ed96ce3..cd4f5772dc 100644 --- a/src/Mod/Arch/ArchSpace.py +++ b/src/Mod/Arch/ArchSpace.py @@ -405,12 +405,12 @@ class _Space(ArchComponent.Component): # 3: identifying boundary faces goodfaces = [] for b in obj.Boundaries: - if hasattr(b[0],'Shape'): - for sub in b[1]: - if "Face" in sub: - fn = int(sub[4:])-1 - faces.append(b[0].Shape.Faces[fn]) - #print("adding face ",fn," of object ",b[0].Name) + if hasattr(b[0],'Shape'): + for sub in b[1]: + if "Face" in sub: + fn = int(sub[4:])-1 + faces.append(b[0].Shape.Faces[fn]) + #print("adding face ",fn," of object ",b[0].Name) #print("total: ", len(faces), " faces") @@ -669,7 +669,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent): if hasattr(self,"font") and hasattr(vobj,"FontName"): self.font.name = str(vobj.FontName) - elif (prop == "FontSize"): + elif prop == "FontSize": if hasattr(self,"font") and hasattr(vobj,"FontSize"): self.font.size = vobj.FontSize.Value if hasattr(vobj,"FirstLine"): @@ -677,7 +677,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent): self.header.scaleFactor.setValue([scale,scale,scale]) self.onChanged(vobj, "TextPosition") - elif (prop == "FirstLine"): + elif prop == "FirstLine": if hasattr(self,"header") and hasattr(vobj,"FontSize") and hasattr(vobj,"FirstLine"): scale = vobj.FirstLine.Value/vobj.FontSize.Value self.header.scaleFactor.setValue([scale,scale,scale]) diff --git a/src/Mod/Arch/ArchVRM.py b/src/Mod/Arch/ArchVRM.py index 6764a37579..b8fd376081 100644 --- a/src/Mod/Arch/ArchVRM.py +++ b/src/Mod/Arch/ArchVRM.py @@ -654,4 +654,3 @@ class Renderer: svg += '"/>\n' svg += '\n' return svg - diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 1d11f39faf..1f931dbe8e 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -1746,12 +1746,12 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent): def flipDirection(self): - if hasattr(self,"Object") and self.Object: - obj = self.Object - if obj.Align == "Left": + if hasattr(self,"Object") and self.Object: + obj = self.Object + if obj.Align == "Left": obj.Align = "Right" FreeCAD.ActiveDocument.recompute() - elif obj.Align == "Right": + elif obj.Align == "Right": obj.Align = "Left" FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index d4c7d37205..a476495784 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -533,13 +533,13 @@ class _CommandWindow: except Exception: pass else: - zfile=zipfile.ZipFile(path) - files=zfile.namelist() + zfile = zipfile.ZipFile(path) + files = zfile.namelist() # check for meta-file if it's really a FreeCAD document if files[0] == "Document.xml": image="thumbnails/Thumbnail.png" if image in files: - image=zfile.read(image) + image = zfile.read(image) thumbfile = tempfile.mkstemp(suffix='.png')[1] thumb = open(thumbfile,"wb") thumb.write(image) diff --git a/src/Mod/Arch/OfflineRenderingUtils.py b/src/Mod/Arch/OfflineRenderingUtils.py index 278a8aa8cf..80b6ade2aa 100755 --- a/src/Mod/Arch/OfflineRenderingUtils.py +++ b/src/Mod/Arch/OfflineRenderingUtils.py @@ -285,7 +285,7 @@ def getColors(filename,nodiffuse=False): if ("DiffuseColor" in v) and (not nodiffuse): if len(v["DiffuseColor"]["value"]) == 1: # only one color in DiffuseColor: used for the whole object - colors[k] = v["DiffuseColor"]["value"][0] + colors[k] = v["DiffuseColor"]["value"][0] else: colors[k] = v["DiffuseColor"]["value"] elif "ShapeColor" in v: diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index d18f65caca..8c940bd953 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -1899,7 +1899,7 @@ def getProfile(ifcfile,p): elif isinstance(p.Edges[0].Curve,Part.Ellipse): # extruded ellipse profile = ifcbin.createIfcEllipseProfileDef("AREA",None,pt,p.Edges[0].Curve.MajorRadius,p.Edges[0].Curve.MinorRadius) - elif (checkRectangle(p.Edges)): + elif checkRectangle(p.Edges): # arbitrarily use the first edge as the rectangle orientation d = vec(p.Edges[0]) d.normalize() @@ -2135,7 +2135,7 @@ def getRepresentation( if obj.isDerivedFrom("Part::Feature"): #if hasattr(obj,"Base") and hasattr(obj,"Additions")and hasattr(obj,"Subtractions"): if False: # above is buggy. No way to duplicate shapes that way? - if obj.Base and (not obj.Additions) and not(obj.Subtractions): + if obj.Base and not obj.Additions and not obj.Subtractions: if obj.Base.isDerivedFrom("Part::Feature"): if obj.Base.Shape: if obj.Base.Shape.Solids: diff --git a/src/Mod/Arch/exportIFCStructuralTools.py b/src/Mod/Arch/exportIFCStructuralTools.py index dbf5e7fd30..beb735ce47 100644 --- a/src/Mod/Arch/exportIFCStructuralTools.py +++ b/src/Mod/Arch/exportIFCStructuralTools.py @@ -214,9 +214,9 @@ def createStructuralMember(ifcfile, ifcbin, obj): # creates geometry verts = [None for _ in range(len(edges))] for i, edge in enumerate(edges): - verts[i] = tuple(edge.Vertexes[0].Point.multiply(scaling)) - cartPnt = ifcfile.createIfcCartesianPoint(verts[i]) - vertPnt = ifcfile.createIfcVertexPoint(cartPnt) + verts[i] = tuple(edge.Vertexes[0].Point.multiply(scaling)) + cartPnt = ifcfile.createIfcCartesianPoint(verts[i]) + vertPnt = ifcfile.createIfcVertexPoint(cartPnt) orientedEdges = [None for _ in range(len(edges))] for i, vert in enumerate(verts): v2Index = (i + 1) if i < len(verts) - 1 else 0 diff --git a/src/Mod/Arch/ifc_objects.py b/src/Mod/Arch/ifc_objects.py index 6aa6a871fc..e83c601726 100644 --- a/src/Mod/Arch/ifc_objects.py +++ b/src/Mod/Arch/ifc_objects.py @@ -25,8 +25,8 @@ class ifc_object: def __init__(self): pass def onDocumentRestored(self, obj): - obj.Type = [obj.IfcType] - obj.Type = obj.IfcType + obj.Type = [obj.IfcType] + obj.Type = obj.IfcType def __getstate__(self): return None def __setstate__(self, state): diff --git a/src/Mod/Arch/importGBXML.py b/src/Mod/Arch/importGBXML.py index d424f2d614..cc13d55d25 100644 --- a/src/Mod/Arch/importGBXML.py +++ b/src/Mod/Arch/importGBXML.py @@ -496,7 +496,3 @@ def export(objectslist,filename): ... repeat ''' - - - - diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index e2811c5689..3a029d40cc 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -610,7 +610,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): baseobj.Dir = ex[1] if FreeCAD.GuiUp: baseface.ViewObject.hide() - if (not baseobj): + if not baseobj: baseobj = doc.addObject("Part::Feature",name+"_body") baseobj.Shape = shape else: @@ -921,7 +921,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # of the (twodimensional) direction vector for TrueNorth shall be greater than zero. (x, y) = modelRC.TrueNorth.DirectionRatios[:2] obj.Declination = ((math.degrees(math.atan2(y,x))-90+180) % 360)-180 - if (FreeCAD.GuiUp): + if FreeCAD.GuiUp: obj.ViewObject.CompassRotation.Value = obj.Declination try: diff --git a/src/Mod/Arch/importOBJ.py b/src/Mod/Arch/importOBJ.py index 99e4ac375e..da45c7b2f5 100644 --- a/src/Mod/Arch/importOBJ.py +++ b/src/Mod/Arch/importOBJ.py @@ -60,9 +60,9 @@ def decode(txt): def findVert(aVertex,aList): "finds aVertex in aList, returns index" for i in range(len(aList)): - if ( round(aVertex.X,p) == round(aList[i].X,p) ): - if ( round(aVertex.Y,p) == round(aList[i].Y,p) ): - if ( round(aVertex.Z,p) == round(aList[i].Z,p) ): + if round(aVertex.X,p) == round(aList[i].X,p): + if round(aVertex.Y,p) == round(aList[i].Y,p): + if round(aVertex.Z,p) == round(aList[i].Z,p): return i return None @@ -105,13 +105,13 @@ def getIndices(obj,shape,offsetv,offsetvn): curves = shape.Topology if mesh: for v in mesh.Topology[0]: - vlist.append(" "+str(round(v[0],p))+" "+str(round(v[1],p))+" "+str(round(v[2],p))) + vlist.append(" "+str(round(v[0],p))+" "+str(round(v[1],p))+" "+str(round(v[2],p))) for vn in mesh.Facets: - vnlist.append(" "+str(vn.Normal[0]) + " " + str(vn.Normal[1]) + " " + str(vn.Normal[2])) + vnlist.append(" "+str(vn.Normal[0]) + " " + str(vn.Normal[1]) + " " + str(vn.Normal[2])) for i, vn in enumerate(mesh.Topology[1]): - flist.append(" "+str(vn[0]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[1]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[2]+offsetv)+"//"+str(i+offsetvn)+" ") + flist.append(" "+str(vn[0]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[1]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[2]+offsetv)+"//"+str(i+offsetvn)+" ") else: if curves: for v in curves[0]: @@ -126,7 +126,7 @@ def getIndices(obj,shape,offsetv,offsetvn): vlist.append(" "+str(round(v.X,p))+" "+str(round(v.Y,p))+" "+str(round(v.Z,p))) if not shape.Faces: for e in shape.Edges: - if DraftGeomUtils.geomType(e) == "Line": + if DraftGeomUtils.geomType(e) == "Line": ei = " " + str(findVert(e.Vertexes[0],shape.Vertexes) + offsetv) ei += " " + str(findVert(e.Vertexes[-1],shape.Vertexes) + offsetv) elist.append(ei) @@ -304,7 +304,7 @@ def insert(filename,docname): meshName = ntpath.basename(filename) for i in meshName.split(): if "." in i: - i = i.split(".")[0] + i = i.split(".")[0] meshName = i "called when freecad wants to import a file" try: