diff --git a/data/tests/Crank.py b/data/tests/Crank.py index a2cb4e4cee..7e96919a8b 100644 --- a/data/tests/Crank.py +++ b/data/tests/Crank.py @@ -6,99 +6,99 @@ import Draft from FreeCAD import Base circ1= Part.makeCircle( - 5, - FreeCAD.Vector(10,18,10), FreeCAD.Vector(1,0,0)) + 5, + FreeCAD.Vector(10,18,10), FreeCAD.Vector(1,0,0)) circ2 = Part.makeCircle(5) def DrawMyPart(points, extrude): - obj1 = Draft.makeWire(points,closed=True,face=True,support=None) - face1 = Part.Face(obj1.Shape) - body1= face1.extrude(extrude) - Part.show(body1) + obj1 = Draft.makeWire(points,closed=True,face=True,support=None) + face1 = Part.Face(obj1.Shape) + body1= face1.extrude(extrude) + Part.show(body1) # part1 DrawMyPart([ - FreeCAD.Vector(0,0,0), - FreeCAD.Vector(45,0,0), - FreeCAD.Vector(45,20,0), - FreeCAD.Vector(0,20,0), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(0,0,0), + FreeCAD.Vector(45,0,0), + FreeCAD.Vector(45,20,0), + FreeCAD.Vector(0,20,0), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(0,20,0), - FreeCAD.Vector(0,180,0), - FreeCAD.Vector(25,180,0), - FreeCAD.Vector(25,20,0), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(0,20,0), + FreeCAD.Vector(0,180,0), + FreeCAD.Vector(25,180,0), + FreeCAD.Vector(25,20,0), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(0,180,0), - FreeCAD.Vector(0,200,0), - FreeCAD.Vector(45,200,0), - FreeCAD.Vector(45,180,0), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(0,180,0), + FreeCAD.Vector(0,200,0), + FreeCAD.Vector(45,200,0), + FreeCAD.Vector(45,180,0), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(25,20,0), - FreeCAD.Vector(25,180,0), - FreeCAD.Vector(25,180,9.2), - FreeCAD.Vector(25,20,9.2), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(25,20,0), + FreeCAD.Vector(25,180,0), + FreeCAD.Vector(25,180,9.2), + FreeCAD.Vector(25,20,9.2), + ], Base.Vector(0,0,4)) # part2 points=[ - FreeCAD.Vector(45,200,0), - FreeCAD.Vector(68,200,25), - FreeCAD.Vector(68,0,25), - FreeCAD.Vector(45,0,0), - FreeCAD.Vector(45,200,0), + FreeCAD.Vector(45,200,0), + FreeCAD.Vector(68,200,25), + FreeCAD.Vector(68,0,25), + FreeCAD.Vector(45,0,0), + FreeCAD.Vector(45,200,0), ] DrawMyPart([ - FreeCAD.Vector(45,200,0), - FreeCAD.Vector(68,200,25), - FreeCAD.Vector(68,180,25), - FreeCAD.Vector(45,180,0), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(45,200,0), + FreeCAD.Vector(68,200,25), + FreeCAD.Vector(68,180,25), + FreeCAD.Vector(45,180,0), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(68,180,25), - FreeCAD.Vector(56.7,180,13), - FreeCAD.Vector(56.7,20,13), - FreeCAD.Vector(68,20,25), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(68,180,25), + FreeCAD.Vector(56.7,180,13), + FreeCAD.Vector(56.7,20,13), + FreeCAD.Vector(68,20,25), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(45,0,0), - FreeCAD.Vector(68,0,25), - FreeCAD.Vector(68,20,25), - FreeCAD.Vector(45,20,0), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(45,0,0), + FreeCAD.Vector(68,0,25), + FreeCAD.Vector(68,20,25), + FreeCAD.Vector(45,20,0), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(25,20,0), - FreeCAD.Vector(45,20,0), - FreeCAD.Vector(45,20,9.2), - FreeCAD.Vector(25,20,9.2), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(25,20,0), + FreeCAD.Vector(45,20,0), + FreeCAD.Vector(45,20,9.2), + FreeCAD.Vector(25,20,9.2), + ], Base.Vector(0,0,4)) DrawMyPart([ - FreeCAD.Vector(25,180,0), - FreeCAD.Vector(45,180,0), - FreeCAD.Vector(45,180,9.2), - FreeCAD.Vector(25,180,9.2), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(25,180,0), + FreeCAD.Vector(45,180,0), + FreeCAD.Vector(45,180,9.2), + FreeCAD.Vector(25,180,9.2), + ], Base.Vector(0,0,4)) # part3 DrawMyPart([ - FreeCAD.Vector(68,200,25), - FreeCAD.Vector(68,200,35), - FreeCAD.Vector(68,0,35), - FreeCAD.Vector(68,0,25), - FreeCAD.Vector(68,200,25), - ], Base.Vector(0,0,4)) + FreeCAD.Vector(68,200,25), + FreeCAD.Vector(68,200,35), + FreeCAD.Vector(68,0,35), + FreeCAD.Vector(68,0,25), + FreeCAD.Vector(68,200,25), + ], Base.Vector(0,0,4)) circ1= Draft.makeCircle( - 5, - Base.Placement(10,18,10), - FreeCAD.Vector(1,0,0)) + 5, + Base.Placement(10,18,10), + FreeCAD.Vector(1,0,0)) circ2 = Draft.makeCircle(5) \ No newline at end of file diff --git a/package/fedora/freecad.spec b/package/fedora/freecad.spec index c701e60bda..45d9b6d41d 100644 --- a/package/fedora/freecad.spec +++ b/package/fedora/freecad.spec @@ -236,8 +236,8 @@ LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS make fc_version for I in src/Build/Version.h src/Build/Version.h.out; do - sed -i 's,FCRevision \"Unknown\",FCRevision \"%{release} (Git)\",' $I - sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' $I + sed -i 's,FCRevision \"Unknown\",FCRevision \"%{release} (Git)\",' $I + sed -i 's,FCRepositoryURL \"Unknown\",FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\",' $I done %{make_build} diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml index d5d54c59e6..ac0f7cea1e 100644 --- a/src/App/DocumentObjectPy.xml +++ b/src/App/DocumentObjectPy.xml @@ -1,18 +1,18 @@ - - - - This is the father of all classes handled by the document - + + + + This is the father of all classes handled by the document + @@ -36,15 +36,15 @@ - - Mark the object as changed (touched) - - - - - Mark the object as unchanged - - + + Mark the object as changed (touched) + + + + + Mark the object as unchanged + + Mark the object for recompute @@ -147,27 +147,27 @@ containing the accumulated transformation matrix - - + + setElementVisible(element,visible): Set the visibility of a child element Return -1 if element visibility is not supported, 0 if element not found, 1 if success - - - - + + + + isElementVisible(element): Check if a child element is visible Return -1 if element visibility is not supported or element not found, 0 if invisible, or else 1 - - - - + + + + Return true to indicate the object having child elements - - + + Returns the group the object is in or None if it is not part of a group. @@ -249,11 +249,11 @@ Return tuple(obj,newElementName,oldElementName) - - Return the internal name of this object - - - + + Return the internal name of this object + + + Return the document this object is part of @@ -261,54 +261,54 @@ Return tuple(obj,newElementName,oldElementName) - - State of the object in the document - - - - - - If the GUI is loaded the associated view provider is returned + + State of the object in the document + + + + + + If the GUI is loaded the associated view provider is returned or None if the GUI is not up - - - - - - + + + + + + Check if the object must be recomputed - - - - - + + + + + The unique identifier (among its document) of this object - - - - - + + + + + Indicate if the object is being removed - - - + + + A List of tuple(parent,subname) holding all parents to this object - + Contains the old label before change - + Enable/disable no touch on any property change - + - + diff --git a/src/App/DocumentPy.xml b/src/App/DocumentPy.xml index 97a419a4ba..14e6f89db6 100644 --- a/src/App/DocumentPy.xml +++ b/src/App/DocumentPy.xml @@ -198,23 +198,23 @@ object of this document. - - Return the object with the given name - - - - - Return the objects with the given label name. + + Return the object with the given name + + + + + Return the objects with the given label name. NOTE: It's possible that several objects have the same label name. - - + + - + findObjects([Type=string], [Name=string], [Label=string]) -> list Return a list of objects that match the specified type, name or label. Name and label support regular expressions. All parameters are optional. - - + + @@ -225,18 +225,18 @@ maxCount: to limit the number of links returned - - - A list of supported types of objects - - - - - Returns a file name with path in the temp directory of the document. - - - - + + + A list of supported types of objects + + + + + Returns a file name with path in the temp directory of the document. + + + + getDependentDocuments(sort=True) @@ -244,21 +244,21 @@ Returns a list of documents that this document directly or indirectly links to i sort: whether to topologically sort the return list - - - - - The dependency graph as GraphViz text - - - - - - The active object of the document - - - - + + + + + The dependency graph as GraphViz text + + + + + + The active object of the document + + + + The list of object handled by this document @@ -330,48 +330,48 @@ sort: whether to topologically sort the return list - - + + A list of all documents that link to this document. - - - - - + + + + + A list of all documents that this document links to. - - - - - + + + + + Indicate if the document is restoring - - - - - + + + + + Indicate if the document is partially loaded - - - - - + + + + + Indicate if the document is importing. Note the document will also report Restoring while importing - - - - - + + + + + Indicate if the document is recomputing - - - - - + + + + + Indicate whether the document is undoing/redoing - - - + + + Contains the old label before change diff --git a/src/App/GroupExtensionPy.xml b/src/App/GroupExtensionPy.xml index 9b0950bbb0..5576a43407 100644 --- a/src/App/GroupExtensionPy.xml +++ b/src/App/GroupExtensionPy.xml @@ -43,12 +43,12 @@ Remove multiple objects from the group. Expects a list and returns all objects that have been removed. - - - Remove all child objects from the group and document - - - + + + Remove all child objects from the group and document + + + Return the object with the given name diff --git a/src/App/PropertyContainerPy.xml b/src/App/PropertyContainerPy.xml index 8e6f0856a3..b0243a1346 100644 --- a/src/App/PropertyContainerPy.xml +++ b/src/App/PropertyContainerPy.xml @@ -33,13 +33,13 @@ name : str\n Property name. - - getTypeOfProperty(name) -> list\n + + getTypeOfProperty(name) -> list\n Returns the type of a named property. This can be a list conformed by elements in (Hidden, NoRecompute, NoPersist, Output, ReadOnly, Transient).\n name : str\n Property name. - - + + getTypeIdOfProperty(name) -> str\n @@ -70,21 +70,21 @@ name : str\n Property name. - - getGroupOfProperty(name) -> str\n + + getGroupOfProperty(name) -> str\n Returns the name of the group which the property belongs to in this class. The properties are sorted in different named groups for convenience.\n name : str\n Property name. - - + + - - setGroupOfProperty(name, group) -> None\n + + setGroupOfProperty(name, group) -> None\n Set the name of the group of a dynamic property.\n name : str\n Property name. group : str\n Group name. - - + + setPropertyStatus(name, val) -> None\n @@ -101,29 +101,29 @@ Get property status.\n name : str\n Property name. If empty, returns a list of supported text names of the status. - - - getDocumentationOfProperty(name) -> str\n + + + getDocumentationOfProperty(name) -> str\n Returns the documentation string of the property of this class.\n name : str\n Property name. - - - - - setDocumentationOfProperty(name, docstring) -> None\n + + + + + setDocumentationOfProperty(name, docstring) -> None\n Set the documentation string of a dynamic property of this class.\n name : str\n Property name. docstring : str\n Documentation string. - - - - - getEnumerationsOfProperty(name) -> list or None\n + + + + + getEnumerationsOfProperty(name) -> list or None\n Return all enumeration strings of the property of this class or None if not a PropertyEnumeration.\n name : str\n Property name. - - + + dumpPropertyContent(Property, Compression=3) -> bytearray\n diff --git a/src/Base/Parameter.xsd b/src/Base/Parameter.xsd index fdd765ae57..58a13cc209 100644 --- a/src/Base/Parameter.xsd +++ b/src/Base/Parameter.xsd @@ -1,8 +1,8 @@  diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 06e98f771e..3a384371bc 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -57,7 +57,7 @@ if(BUILD_GUI) ) elseif(APPLE AND NOT BUILD_WITH_CONDA) INSTALL(TARGETS FreeCADMain - RUNTIME DESTINATION MacOS + RUNTIME DESTINATION MacOS LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) else() diff --git a/src/Mod/Import/InitGui.py b/src/Mod/Import/InitGui.py index fa535cb731..1a69bca426 100644 --- a/src/Mod/Import/InitGui.py +++ b/src/Mod/Import/InitGui.py @@ -37,39 +37,39 @@ FreeCAD.addExportType("glTF (*.gltf *.glb)","ImportGui") """ class ImportWorkbench ( Workbench ): - "Import workbench object" - def Activate(self): - # load the module - try: - Log ('Loading ImportGui module') - import Import - import ImportGui - except ImportError: - Err('Cannot load ImportGui') - raise - def GetIcon(self): - # returns an icon for the workbench - return ["/* XPM */\n" - "static const char *fileopen[] = {\n" - "\"16 13 5 1\",\n" - "\". c #040404\",\n" - "\"# c #808304\",\n" - "\"a c None\",\n" - "\"b c #f3f704\",\n" - "\"c c #f3f7f3\",\n" - "\"aaaaaaaaa...aaaa\",\n" - "\"aaaaaaaa.aaa.a.a\",\n" - "\"aaaaaaaaaaaaa..a\",\n" - "\"a...aaaaaaaa...a\",\n" - "\".bcb.......aaaaa\",\n" - "\".cbcbcbcbc.aaaaa\",\n" - "\".bcbcbcbcb.aaaaa\",\n" - "\".cbcb...........\",\n" - "\".bcb.#########.a\",\n" - "\".cb.#########.aa\",\n" - "\".b.#########.aaa\",\n" - "\"..#########.aaaa\",\n" - "\"...........aaaaa\"};\n"] + "Import workbench object" + def Activate(self): + # load the module + try: + Log ('Loading ImportGui module') + import Import + import ImportGui + except ImportError: + Err('Cannot load ImportGui') + raise + def GetIcon(self): + # returns an icon for the workbench + return ["/* XPM */\n" + "static const char *fileopen[] = {\n" + "\"16 13 5 1\",\n" + "\". c #040404\",\n" + "\"# c #808304\",\n" + "\"a c None\",\n" + "\"b c #f3f704\",\n" + "\"c c #f3f7f3\",\n" + "\"aaaaaaaaa...aaaa\",\n" + "\"aaaaaaaa.aaa.a.a\",\n" + "\"aaaaaaaaaaaaa..a\",\n" + "\"a...aaaaaaaa...a\",\n" + "\".bcb.......aaaaa\",\n" + "\".cbcbcbcbc.aaaaa\",\n" + "\".bcbcbcbcb.aaaaa\",\n" + "\".cbcb...........\",\n" + "\".bcb.#########.a\",\n" + "\".cb.#########.aa\",\n" + "\".b.#########.aaa\",\n" + "\"..#########.aaaa\",\n" + "\"...........aaaaa\"};\n"] Gui.addWorkbench("Import",ImportWorkbench()) """ diff --git a/src/Tools/chm.css b/src/Tools/chm.css index 1e839d63a7..b5dc000550 100644 --- a/src/Tools/chm.css +++ b/src/Tools/chm.css @@ -7,13 +7,13 @@ a.new{ color:#ba0000; text-decoration:none; } padding:5px; } .tocindent { - margin-left: 2em; + margin-left: 2em; } .tocline { - margin-bottom: 0px; + margin-bottom: 0px; } .toctoggle, .editsection { - font-size: smaller; + font-size: smaller; } /* images */ @@ -126,7 +126,7 @@ p, .documentDescription { } .tocindent p { - margin: 0 0 0 0 ! important; + margin: 0 0 0 0 ! important; } pre { @@ -135,8 +135,8 @@ pre { font-size: 95%; overflow: auto; padding: 5px; - background : #F9F9F9; - color : black; + background : #F9F9F9; + color : black; } table.listing, @@ -167,8 +167,8 @@ a:link, a:visited { } #content { - background : white; - color : black; + background : white; + color : black; } #column-content { @@ -181,14 +181,14 @@ a:link, a:visited { } /* MSIE/Win doesn't understand 'inherit' */ /*a, a.external, a.new, a.stub { - color: black ! important; - text-decoration: none ! important; + color: black ! important; + text-decoration: none ! important; } */ /* Continue ... */ /*a, a.external, a.new, a.stub { - color: inherit ! important; - text-decoration: inherit ! important; + color: inherit ! important; + text-decoration: inherit ! important; } */ img { border: none; } diff --git a/src/Tools/dir2qrc.py b/src/Tools/dir2qrc.py index 9cd7b517c5..adcf5f50d9 100644 --- a/src/Tools/dir2qrc.py +++ b/src/Tools/dir2qrc.py @@ -67,89 +67,89 @@ locations = [["../Gui/Language","translation.qrc"," prefix=\"/translations\""], ["../Mod/Sketcher/Gui/Resources","Sketcher.qrc"]] def main(): - global Verbose,Automatic,ExtraDist,Dir,Output - - try: - opts, args = getopt.getopt(sys.argv[1:], "hvd:o:", ["help", "verbose", "auto", "dist", "directory=","out-file="]) - except getopt.GetoptError: - # print help information and exit: - sys.stderr.write(Usage) - sys.exit(2) + global Verbose,Automatic,ExtraDist,Dir,Output + + try: + opts, args = getopt.getopt(sys.argv[1:], "hvd:o:", ["help", "verbose", "auto", "dist", "directory=","out-file="]) + except getopt.GetoptError: + # print help information and exit: + sys.stderr.write(Usage) + sys.exit(2) - # checking on the options - for o, a in opts: - if o == "-v": - Verbose = True - if o in ("-h", "--help"): - sys.stderr.write(Usage) - sys.exit() - if o in ("-a", "--auto"): - Automatic = True - if o in ("--dist"): - ExtraDist = True - if o in ("-o", "--out-file"): - Output = a - if o in ("-d", "--directory"): - print("Using path: " + a +"\n") - Dir = a - - if Automatic: - path = os.path.realpath(__file__) - path = os.path.dirname(path) - for i in locations: - qrcDir = os.path.realpath(join(path,i[0])) - if len(i) > 2: - updateResourceFile(qrcDir,i[1],i[2]) - else: - updateResourceFile(qrcDir,i[1]) - if ExtraDist: - makeTargetExtraDist(qrcDir) - else: - updateResourceFile(Dir, Output) - if ExtraDist: - makeTargetExtraDist(Dir) + # checking on the options + for o, a in opts: + if o == "-v": + Verbose = True + if o in ("-h", "--help"): + sys.stderr.write(Usage) + sys.exit() + if o in ("-a", "--auto"): + Automatic = True + if o in ("--dist"): + ExtraDist = True + if o in ("-o", "--out-file"): + Output = a + if o in ("-d", "--directory"): + print("Using path: " + a +"\n") + Dir = a + + if Automatic: + path = os.path.realpath(__file__) + path = os.path.dirname(path) + for i in locations: + qrcDir = os.path.realpath(join(path,i[0])) + if len(i) > 2: + updateResourceFile(qrcDir,i[1],i[2]) + else: + updateResourceFile(qrcDir,i[1]) + if ExtraDist: + makeTargetExtraDist(qrcDir) + else: + updateResourceFile(Dir, Output) + if ExtraDist: + makeTargetExtraDist(Dir) def updateResourceFile(Dir, Output,prefix=""): - global Verbose - Output = join(Dir,Output) - file = open(Output,"w") - file.write(hhcHeader % (prefix)) - DirPath = Dir + os.path.sep - filelist=[] - for root, dirs, files in os.walk(Dir): - for name in files: - if ( (1 in [c in name for c in EndingList]) and not ('.svn' in root) ): - FilePathOrg = join(root,name) - FilePath = FilePathOrg.replace(DirPath,'') - FilePath = FilePath.replace('.\\','') - FilePath = FilePath.replace('\\','/') - if Verbose: print(FilePathOrg + ' -> ' + FilePath) - filelist.append(FilePath) + global Verbose + Output = join(Dir,Output) + file = open(Output,"w") + file.write(hhcHeader % (prefix)) + DirPath = Dir + os.path.sep + filelist=[] + for root, dirs, files in os.walk(Dir): + for name in files: + if ( (1 in [c in name for c in EndingList]) and not ('.svn' in root) ): + FilePathOrg = join(root,name) + FilePath = FilePathOrg.replace(DirPath,'') + FilePath = FilePath.replace('.\\','') + FilePath = FilePath.replace('\\','/') + if Verbose: print(FilePathOrg + ' -> ' + FilePath) + filelist.append(FilePath) - filelist.sort() - for i in filelist: - file.write(' ' + i + '\n') + filelist.sort() + for i in filelist: + file.write(' ' + i + '\n') - file.write(hhcFooter) - file.close() + file.write(hhcFooter) + file.close() def makeTargetExtraDist(Dir): - extensions = EndingList[:] - extensions.append(".qrc") - extensions.append(".bat") - extensions.append(".ts") - print("EXTRA_DIST = \\") - DirPath = Dir + os.path.sep - for root, dirs, files in os.walk(Dir): - for name in files: - if ( (1 in [c in name for c in extensions]) and not ('.svn' in root) ): - FilePathOrg = join(root,name) - FilePath = FilePathOrg.replace(DirPath,'') - FilePath = FilePath.replace('.\\','') - FilePath = FilePath.replace('\\','/') - print("\t\t%s \\" % (FilePath)) - print() + extensions = EndingList[:] + extensions.append(".qrc") + extensions.append(".bat") + extensions.append(".ts") + print("EXTRA_DIST = \\") + DirPath = Dir + os.path.sep + for root, dirs, files in os.walk(Dir): + for name in files: + if ( (1 in [c in name for c in extensions]) and not ('.svn' in root) ): + FilePathOrg = join(root,name) + FilePath = FilePathOrg.replace(DirPath,'') + FilePath = FilePath.replace('.\\','') + FilePath = FilePath.replace('\\','/') + print("\t\t%s \\" % (FilePath)) + print() if __name__ == "__main__": - main() + main() diff --git a/src/Tools/doctools.py b/src/Tools/doctools.py index 321725e6d2..9d7bae667f 100644 --- a/src/Tools/doctools.py +++ b/src/Tools/doctools.py @@ -11,59 +11,59 @@ import zipfile # SAX handler to parse the Document.xml class DocumentHandler(xml.sax.handler.ContentHandler): - def __init__(self, dirname): - super().__init__() - self.files = [] - self.dirname = dirname + def __init__(self, dirname): + super().__init__() + self.files = [] + self.dirname = dirname - def startElement(self, name, attributes): - item=attributes.get("file") - if item is not None: - self.files.append(os.path.join(self.dirname,str(item))) + def startElement(self, name, attributes): + item=attributes.get("file") + if item is not None: + self.files.append(os.path.join(self.dirname,str(item))) - def characters(self, data): - return + def characters(self, data): + return - def endElement(self, name): - return + def endElement(self, name): + return def extractDocument(filename, outpath): - zfile=zipfile.ZipFile(filename) - files=zfile.namelist() - - for i in files: - data=zfile.read(i) - dirs=i.split("/") - if len(dirs) > 1: - dirs.pop() - curpath=outpath - for j in dirs: - curpath=curpath+"/"+j - os.mkdir(curpath) - output=open(outpath+"/"+i,'wb') - output.write(data) - output.close() + zfile=zipfile.ZipFile(filename) + files=zfile.namelist() + + for i in files: + data=zfile.read(i) + dirs=i.split("/") + if len(dirs) > 1: + dirs.pop() + curpath=outpath + for j in dirs: + curpath=curpath+"/"+j + os.mkdir(curpath) + output=open(outpath+"/"+i,'wb') + output.write(data) + output.close() def createDocument(filename, outpath): - files=getFilesList(filename) - compress=zipfile.ZipFile(outpath,'w',zipfile.ZIP_DEFLATED) - for i in files: - dirs=os.path.split(i) - #print i, dirs[-1] - compress.write(i,dirs[-1],zipfile.ZIP_DEFLATED) - compress.close() + files=getFilesList(filename) + compress=zipfile.ZipFile(outpath,'w',zipfile.ZIP_DEFLATED) + for i in files: + dirs=os.path.split(i) + #print i, dirs[-1] + compress.write(i,dirs[-1],zipfile.ZIP_DEFLATED) + compress.close() def getFilesList(filename): - dirname=os.path.dirname(filename) - handler=DocumentHandler(dirname) - parser=xml.sax.make_parser() - parser.setContentHandler(handler) - parser.parse(filename) + dirname=os.path.dirname(filename) + handler=DocumentHandler(dirname) + parser=xml.sax.make_parser() + parser.setContentHandler(handler) + parser.parse(filename) - files=[] - files.append(filename) - files.extend(iter(handler.files)) - dirname=os.path.join(dirname,"GuiDocument.xml") - if os.path.exists(dirname): - files.append(dirname) - return files + files=[] + files.append(filename) + files.extend(iter(handler.files)) + dirname=os.path.join(dirname,"GuiDocument.xml") + if os.path.exists(dirname): + files.append(dirname) + return files diff --git a/src/Tools/examplePy2wiki.py b/src/Tools/examplePy2wiki.py index 4801160f04..7edf31683d 100644 --- a/src/Tools/examplePy2wiki.py +++ b/src/Tools/examplePy2wiki.py @@ -37,28 +37,28 @@ def Process(line): def main(): - try: - opts, args = getopt.getopt(sys.argv[1:], "hi:o:", ["help", "verbose", "in-file=","out-file="]) - except getopt.GetoptError: - # print help information and exit: - sys.stderr.write(Usage) - sys.exit(2) + try: + opts, args = getopt.getopt(sys.argv[1:], "hi:o:", ["help", "verbose", "in-file=","out-file="]) + except getopt.GetoptError: + # print help information and exit: + sys.stderr.write(Usage) + sys.exit(2) - # checking on the options - for o, a in opts: - if o in ("-h", "--help"): - sys.stderr.write(Usage) - sys.exit() - if o in ("-o", "--out-file"): - outfile = open(a,'w') - if o in ("-i", "--in-file"): - infile = open(a,'r') - + # checking on the options + for o, a in opts: + if o in ("-h", "--help"): + sys.stderr.write(Usage) + sys.exit() + if o in ("-o", "--out-file"): + outfile = open(a,'w') + if o in ("-i", "--in-file"): + infile = open(a,'r') + - lines = infile.readlines() - for l in lines: - outfile.write(Process(l)) - #print l - + lines = infile.readlines() + for l in lines: + outfile.write(Process(l)) + #print l + if __name__ == "__main__": - main() + main() diff --git a/src/Tools/fcbt.py b/src/Tools/fcbt.py index cb6fd467e5..c8b2fc22f9 100644 --- a/src/Tools/fcbt.py +++ b/src/Tools/fcbt.py @@ -25,37 +25,37 @@ For help on the modules type: """ if(len(sys.argv) < 2): - sys.stdout.write(help1) - sys.stdout.write("Insert command: ") - sys.stdout.flush() - CmdRaw = sys.stdin.readline()[:-1] + sys.stdout.write(help1) + sys.stdout.write("Insert command: ") + sys.stdout.flush() + CmdRaw = sys.stdin.readline()[:-1] else: - CmdRaw = sys.argv[1] - + CmdRaw = sys.argv[1] + Cmd = CmdRaw.lower() if Cmd == "distsrc" or Cmd == "ds" : - import fcbt.DistSrc + import fcbt.DistSrc elif Cmd == "distbin" or Cmd == "db": - import fcbt.DistBin + import fcbt.DistBin elif Cmd == "distsetup" or Cmd == "di": - import fcbt.DistSetup + import fcbt.DistSetup elif Cmd == "distsetup" or Cmd == "dui": - import fcbt.DistUserSetup + import fcbt.DistUserSetup elif Cmd == "distall" or Cmd == "da": - import fcbt.DistSrc - import fcbt.DistBin - import fcbt.DistSetup + import fcbt.DistSrc + import fcbt.DistBin + import fcbt.DistSetup elif Cmd == "nextbuildnumber" or Cmd == "nbn": - import fcbt.NextBuildNumber + import fcbt.NextBuildNumber elif Cmd == "createmodule" or Cmd == "cm": - import fcbt.CreateModule + import fcbt.CreateModule elif Cmd == "createpymodule" or Cmd == "cp": - import fcbt.CreatePyModule + import fcbt.CreatePyModule elif Cmd == "?" or Cmd == "help" or Cmd == "/h" or Cmd == "/?" or Cmd == "-h" or Cmd == "-help": - sys.stdout.write(help1) + sys.stdout.write(help1) else: - print(CmdRaw + " is an unknown command!\n") - sys.exit(1) + print(CmdRaw + " is an unknown command!\n") + sys.exit(1) diff --git a/src/Tools/fcbt/CreateModule.py b/src/Tools/fcbt/CreateModule.py index e23390fe38..7dd00d7d29 100644 --- a/src/Tools/fcbt/CreateModule.py +++ b/src/Tools/fcbt/CreateModule.py @@ -72,47 +72,47 @@ def SetupFilter(MatchList): def createApp(Application): - """ - Create a new application by copying the template - """ - # create directory ../Mod/ - if not os.path.isdir("../Mod/"+Application): - os.mkdir("../Mod/"+Application) - else: - sys.stdout.write(Application + " already exists. Please enter another name.\n") - sys.exit() + """ + Create a new application by copying the template + """ + # create directory ../Mod/ + if not os.path.isdir("../Mod/"+Application): + os.mkdir("../Mod/"+Application) + else: + sys.stdout.write(Application + " already exists. Please enter another name.\n") + sys.exit() - # copying files from _TEMPLATE_ to ../Mod/ - sys.stdout.write("Copying files...") - MakeAppTools.copyTemplate("_TEMPLATE_","../Mod/"+Application,"_TEMPLATE_", Application, SetupFilter(FilFilter),SetupFilter(DirFilter)) - sys.stdout.write("Ok\n") + # copying files from _TEMPLATE_ to ../Mod/ + sys.stdout.write("Copying files...") + MakeAppTools.copyTemplate("_TEMPLATE_","../Mod/"+Application,"_TEMPLATE_", Application, SetupFilter(FilFilter),SetupFilter(DirFilter)) + sys.stdout.write("Ok\n") - # replace the _TEMPLATE_ string by - sys.stdout.write("Modifying files...\n") - MakeAppTools.replaceTemplate("../Mod/" + Application,"_TEMPLATE_",Application) - MakeAppTools.replaceTemplate("../Mod/" + Application,"${CMAKE_SOURCE_DIR}/src/Tools/","${CMAKE_SOURCE_DIR}/src/Mod/") - # make the configure script executable - #os.chmod("../Mod/" + Application + "/configure", 0777); - sys.stdout.write("Modifying files done.\n") + # replace the _TEMPLATE_ string by + sys.stdout.write("Modifying files...\n") + MakeAppTools.replaceTemplate("../Mod/" + Application,"_TEMPLATE_",Application) + MakeAppTools.replaceTemplate("../Mod/" + Application,"${CMAKE_SOURCE_DIR}/src/Tools/","${CMAKE_SOURCE_DIR}/src/Mod/") + # make the configure script executable + #os.chmod("../Mod/" + Application + "/configure", 0777); + sys.stdout.write("Modifying files done.\n") - sys.stdout.write(Application + " module created successfully.\n") + sys.stdout.write(Application + " module created successfully.\n") def validateApp(AppName): - """ - Validates the class name - """ - if(len(AppName) < 2): - sys.stdout.write("Too short name: '"+AppName+"'\n") - sys.exit() - # name is long enough - clName="class "+AppName+": self=0" - try: - exec(clName) - except Exception: - # Invalid class name - sys.stdout.write("Invalid name: '"+AppName+"'\n") - sys.exit() + """ + Validates the class name + """ + if(len(AppName) < 2): + sys.stdout.write("Too short name: '"+AppName+"'\n") + sys.exit() + # name is long enough + clName="class "+AppName+": self=0" + try: + exec(clName) + except Exception: + # Invalid class name + sys.stdout.write("Invalid name: '"+AppName+"'\n") + sys.exit() sys.stdout.write("Please enter a name for your application:") sys.stdout.flush() diff --git a/src/Tools/generate.py b/src/Tools/generate.py index 3d63ad7749..e46d051c47 100644 --- a/src/Tools/generate.py +++ b/src/Tools/generate.py @@ -23,7 +23,7 @@ Generate source code out of an model definition. Author: (c) 2006 Juergen Riegel juergen.riegel@web.de - Licence: GPL + Licence: GPL Version: 0.2 diff --git a/src/Tools/generateBase/generateTools.py b/src/Tools/generateBase/generateTools.py index ee65d00802..29955d0169 100644 --- a/src/Tools/generateBase/generateTools.py +++ b/src/Tools/generateBase/generateTools.py @@ -22,20 +22,20 @@ def temporary_exec(text, globals, locals): def ensureDir(path,mode=0o777): - try: - os.makedirs(path,mode) - except OSError as err: - # https://docs.python.org/3/tutorial/errors.html - # raise an error unless it's about an already existing directory - print("Dir Exist") - #if errno != 17 or not os.path.isdir(path): - # raise - + try: + os.makedirs(path,mode) + except OSError as err: + # https://docs.python.org/3/tutorial/errors.html + # raise an error unless it's about an already existing directory + print("Dir Exist") + #if errno != 17 or not os.path.isdir(path): + # raise + def convertMultilineString(str): - str = str.replace('\n','\\n') - str = str.replace('"','\\"') - return str - + str = str.replace('\n','\\n') + str = str.replace('"','\\"') + return str + "Yet Another Python Templating Utility, Version 1.2" import sys diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 150d521c7f..8b08d30c2a 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -9,33 +9,33 @@ import generateBase.generateModel_Module import generateBase.generateTools class TemplateClassPyExport (template.ModelTemplate): - def Generate(self): - #self.ParentNamespace = "Base" - #self.Namespace = "Base" - encoding = sys.getfilesystemencoding() - path = self.path - if hasattr(path,"decode"): # this is python2. Otherwise this is unicode already - path = path.decode(encoding) - exportName = self.export.Name - if hasattr(exportName,"decode"): # this is python2. Otherwise this is unicode already - exportName = exportName.decode(encoding) - dirname = self.dirname - if hasattr(dirname,"decode"): # this is python2. Otherwise this is unicode already - dirname = dirname.decode(encoding) - print("TemplateClassPyExport",path + exportName) - # Imp.cpp must not exist, neither in path nor in dirname - if(not os.path.exists(path + exportName + "Imp.cpp")): - if(not os.path.exists(dirname + exportName + "Imp.cpp")): - file = open(path + exportName + "Imp.cpp",'wb') - generateBase.generateTools.replace(self.TemplateImplement,locals(),file) - file.close() - with open(path + exportName + ".cpp", 'wb') as file: - generateBase.generateTools.replace(self.TemplateModule,locals(),file) - with open(path + exportName + ".h", 'wb') as file: - generateBase.generateTools.replace(self.TemplateHeader,locals(),file) - #file.write( generateBase.generateTools.replace(self.Template,locals())) + def Generate(self): + #self.ParentNamespace = "Base" + #self.Namespace = "Base" + encoding = sys.getfilesystemencoding() + path = self.path + if hasattr(path,"decode"): # this is python2. Otherwise this is unicode already + path = path.decode(encoding) + exportName = self.export.Name + if hasattr(exportName,"decode"): # this is python2. Otherwise this is unicode already + exportName = exportName.decode(encoding) + dirname = self.dirname + if hasattr(dirname,"decode"): # this is python2. Otherwise this is unicode already + dirname = dirname.decode(encoding) + print("TemplateClassPyExport",path + exportName) + # Imp.cpp must not exist, neither in path nor in dirname + if(not os.path.exists(path + exportName + "Imp.cpp")): + if(not os.path.exists(dirname + exportName + "Imp.cpp")): + file = open(path + exportName + "Imp.cpp",'wb') + generateBase.generateTools.replace(self.TemplateImplement,locals(),file) + file.close() + with open(path + exportName + ".cpp", 'wb') as file: + generateBase.generateTools.replace(self.TemplateModule,locals(),file) + with open(path + exportName + ".h", 'wb') as file: + generateBase.generateTools.replace(self.TemplateHeader,locals(),file) + #file.write( generateBase.generateTools.replace(self.Template,locals())) - TemplateHeader = """ + TemplateHeader = """ // This file is generated by src/Tools/generateTemplates/templateClassPyExport.py out of the XML file // Every change you make here gets lost in the next full rebuild! #ifndef @self.export.Namespace.upper().replace("::", "_")@_@self.export.Name.upper()@_H @@ -252,7 +252,7 @@ public: """ - TemplateModule = """ + TemplateModule = """ // This file is generated by src/Tools/generateTemplates/templateClassPyExport.py out of the .XML file // Every change you make here gets lost in the next full rebuild! // This File is normally built as an include in @self.export.Name@Imp.cpp! It's not intended to be in a project! @@ -1136,8 +1136,8 @@ int @self.export.Name@::setCustomAttributes(const char* /*attr*/, PyObject* /*ob """ - # Here's the template for the user part of the implementation. This does NOT get overridden if it already exists. - TemplateImplement = """ + # Here's the template for the user part of the implementation. This does NOT get overridden if it already exists. + TemplateImplement = """ #include "PreCompiled.h" #include "@self.export.Include@" diff --git a/src/Tools/generateTemplates/templateModuleApp.py b/src/Tools/generateTemplates/templateModuleApp.py index 6c36420929..6097c234b1 100644 --- a/src/Tools/generateTemplates/templateModuleApp.py +++ b/src/Tools/generateTemplates/templateModuleApp.py @@ -7,23 +7,23 @@ import generateBase.generateModel_Module import generateBase.generateTools class TemplateModuleApp (template.ModelTemplate): - def Generate(self): - AppPath = self.path + "/App/" - generateBase.generateTools.ensureDir(AppPath) - - # the main module files - AppMain= templateModuleAppMain.TemplateModuleAppMain() - AppMain.path = AppPath - AppMain.module = self.module - AppMain.Generate() - - # Features - generateBase.generateTools.ensureDir(AppPath + "Features/") - for i in self.module.Content.Feature: - AppFeature = templateModuleAppFeature.TemplateFeature() - AppFeature.path = AppPath + "Features/" - AppFeature.module = self.module - AppFeature.feature = i - AppFeature.Generate() - - + def Generate(self): + AppPath = self.path + "/App/" + generateBase.generateTools.ensureDir(AppPath) + + # the main module files + AppMain= templateModuleAppMain.TemplateModuleAppMain() + AppMain.path = AppPath + AppMain.module = self.module + AppMain.Generate() + + # Features + generateBase.generateTools.ensureDir(AppPath + "Features/") + for i in self.module.Content.Feature: + AppFeature = templateModuleAppFeature.TemplateFeature() + AppFeature.path = AppPath + "Features/" + AppFeature.module = self.module + AppFeature.feature = i + AppFeature.Generate() + + diff --git a/src/Tools/generateTemplates/templateModuleAppFeature.py b/src/Tools/generateTemplates/templateModuleAppFeature.py index 7b02aae87f..c56f6c4b3f 100644 --- a/src/Tools/generateTemplates/templateModuleAppFeature.py +++ b/src/Tools/generateTemplates/templateModuleAppFeature.py @@ -7,16 +7,16 @@ import generateBase.generateModel_Module import generateBase.generateTools class TemplateFeature (template.ModelTemplate): - def Generate(self): - file = open(self.path + self.feature.Name + "Imp.cpp",'w') - generateBase.generateTools.replace(self.TemplateImplement,locals(),file) - file = open(self.path + self.feature.Name + ".cpp",'w') - generateBase.generateTools.replace(self.TemplateModule,locals(),file) - file = open(self.path + self.feature.Name + ".h",'w') - generateBase.generateTools.replace(self.TemplateHeader,locals(),file) - #file.write( generateBase.generateTools.replace(self.Template,locals())) + def Generate(self): + file = open(self.path + self.feature.Name + "Imp.cpp",'w') + generateBase.generateTools.replace(self.TemplateImplement,locals(),file) + file = open(self.path + self.feature.Name + ".cpp",'w') + generateBase.generateTools.replace(self.TemplateModule,locals(),file) + file = open(self.path + self.feature.Name + ".h",'w') + generateBase.generateTools.replace(self.TemplateHeader,locals(),file) + #file.write( generateBase.generateTools.replace(self.Template,locals())) - TemplateHeader = """ + TemplateHeader = """ #ifndef @self.module.Name.upper()@_FEATURE_@self.feature.Name.upper()@_H #define @self.module.Name.upper()@_FEATURE_@self.feature.Name.upper()@_H @@ -54,7 +54,7 @@ public: #endif // @self.module.Name.upper()@_FEATURE_@self.feature.Name.upper()@_H """ - TemplateModule = """ + TemplateModule = """ #include "PreCompiled.h" #include "@self.feature.Name@.h" @@ -70,8 +70,8 @@ PROPERTY_SOURCE(@self.module.Name@::@self.feature.Name@, App::Feature) - } """ - # Here's the template for the user part of the implementation. This does NOT get overwritten if it already exists. - TemplateImplement = """ + # Here's the template for the user part of the implementation. This does NOT get overwritten if it already exists. + TemplateImplement = """ // #include "PreCompiled.h" diff --git a/src/Tools/generateTemplates/templateModuleAppMain.py b/src/Tools/generateTemplates/templateModuleAppMain.py index 920e9ddca7..7ba8b3264f 100644 --- a/src/Tools/generateTemplates/templateModuleAppMain.py +++ b/src/Tools/generateTemplates/templateModuleAppMain.py @@ -7,12 +7,12 @@ import generateBase.generateModel_Module import generateBase.generateTools class TemplateModuleAppMain (template.ModelTemplate): - def Generate(self): - file = open(self.path + "/App" + self.module.Name + ".cpp",'w') - generateBase.generateTools.replace(self.Template,locals(),file) - #file.write( generateBase.generateTools.replace(self.Template,locals())) + def Generate(self): + file = open(self.path + "/App" + self.module.Name + ".cpp",'w') + generateBase.generateTools.replace(self.Template,locals(),file) + #file.write( generateBase.generateTools.replace(self.Template,locals())) - Template = """ + Template = """ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * @@ -46,7 +46,7 @@ void App@self.module.Name@Export init@self.module.Name@() { @self.module.Name@::Feature@i.Name@::init(); - - return; + return; } } // extern "C" diff --git a/src/Tools/pythondoc.py b/src/Tools/pythondoc.py index 846f94c99c..eb8eaadd88 100644 --- a/src/Tools/pythondoc.py +++ b/src/Tools/pythondoc.py @@ -6,83 +6,83 @@ import pydoc, pkgutil, sys, os, dircache, zipfile def generateDoc(): - # Get the path to the FreeCAD module relative to this directory - toolspath = os.path.dirname(__file__) - homepath = toolspath + '/../../' - homepath = os.path.realpath(homepath) - binpath = os.path.join(homepath, 'bin') - docpath = os.path.join(homepath, 'doc') - modpath = os.path.join(homepath, 'Mod') + # Get the path to the FreeCAD module relative to this directory + toolspath = os.path.dirname(__file__) + homepath = toolspath + '/../../' + homepath = os.path.realpath(homepath) + binpath = os.path.join(homepath, 'bin') + docpath = os.path.join(homepath, 'doc') + modpath = os.path.join(homepath, 'Mod') - # Change to the doc directory - cwd = os.getcwd() - print('Change to ' + docpath) - os.chdir(homepath) - if os.path.exists('doc') == False: - os.mkdir('doc') - os.chdir('doc') + # Change to the doc directory + cwd = os.getcwd() + print('Change to ' + docpath) + os.chdir(homepath) + if os.path.exists('doc') == False: + os.mkdir('doc') + os.chdir('doc') - # Add the bin path to the system path - if os.name == 'nt': - os.environ['PATH'] = os.environ['PATH'] + ';' + binpath - else: - os.environ['PATH'] = os.environ['PATH'] + ':' + binpath + # Add the bin path to the system path + if os.name == 'nt': + os.environ['PATH'] = os.environ['PATH'] + ';' + binpath + else: + os.environ['PATH'] = os.environ['PATH'] + ':' + binpath - # Import FreeCAD module - sys.path.append(binpath) - print('Write documentation for module \'FreeCAD\'') - pydoc.writedoc('FreeCAD') - print('') + # Import FreeCAD module + sys.path.append(binpath) + print('Write documentation for module \'FreeCAD\'') + pydoc.writedoc('FreeCAD') + print('') - # Module directory - ModDirs = dircache.listdir(modpath) + # Module directory + ModDirs = dircache.listdir(modpath) - # Search for module paths and append them to Python path - #for Dir in ModDirs: - # if (Dir != '__init__.py'): - # sys.path.append( os.path.join(modpath,Dir) ) + # Search for module paths and append them to Python path + #for Dir in ModDirs: + # if (Dir != '__init__.py'): + # sys.path.append( os.path.join(modpath,Dir) ) - # Walk through the module paths again and try loading the modules to create HTML files - for Dir in ModDirs: - dest = os.path.join(modpath,Dir) - print('Write documentation for module \'' + Dir + '\'') - if (Dir != '__init__.py'): - writedocs(dest) - print('') + # Walk through the module paths again and try loading the modules to create HTML files + for Dir in ModDirs: + dest = os.path.join(modpath,Dir) + print('Write documentation for module \'' + Dir + '\'') + if (Dir != '__init__.py'): + writedocs(dest) + print('') - # Now we must create a document and create instances of all Python classes which - # cannot be directly created by a module. + # Now we must create a document and create instances of all Python classes which + # cannot be directly created by a module. - # Create a ZIP archive from all HTML files - print('Creating ZIP archive \'docs.zip\'...') - zip = zipfile.ZipFile('docs.zip', 'w') - for file in os.listdir('.'): - if not os.path.isdir(file): - if file.find('.html') > 0: - print(' Adding file ' + file + ' to archive') - zip.write(file) + # Create a ZIP archive from all HTML files + print('Creating ZIP archive \'docs.zip\'...') + zip = zipfile.ZipFile('docs.zip', 'w') + for file in os.listdir('.'): + if not os.path.isdir(file): + if file.find('.html') > 0: + print(' Adding file ' + file + ' to archive') + zip.write(file) - print('done.') - zip.close() + print('done.') + zip.close() - # Remove all HTML files - print('Cleaning up HTML files...') - for file in os.listdir('.'): - if not os.path.isdir(file): - if file.find('.html') > 0: - print(' Removing ' + file) - os.remove(file) + # Remove all HTML files + print('Cleaning up HTML files...') + for file in os.listdir('.'): + if not os.path.isdir(file): + if file.find('.html') > 0: + print(' Removing ' + file) + os.remove(file) - os.chdir(cwd) - print('done.') + os.chdir(cwd) + print('done.') def writedocs(dir, pkgpath=''): """Write out HTML documentation for all modules in a directory tree.""" for importer, modname, ispkg in pkgutil.walk_packages([dir], pkgpath): - # Ignore all debug modules - if modname[-2:] != '_d': - pydoc.writedoc(modname) + # Ignore all debug modules + if modname[-2:] != '_d': + pydoc.writedoc(modname) return if __name__ == "__main__": - generateDoc() + generateDoc()