2 Prepare is a script to remove the generated files, run wikifier, and finally zip the package.
6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
10 from fabmetheus_utilities import archive
11 from fabmetheus_utilities.fabmetheus_tools import wikifier
15 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
16 __date__ = '$Date: 2008/21/04 $'
17 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
21 'Remove generated files, then wikify the file comments.'
22 removeGeneratedFiles()
26 def removeCSVFile(csvFilePath):
28 if 'alterations' in csvFilePath and 'example_' not in csvFilePath:
29 os.remove(csvFilePath)
30 print('removeGeneratedFiles deleted ' + csvFilePath)
32 def removeGcodeFile(gcodeFilePath):
34 if 'alterations' not in gcodeFilePath:
35 os.remove(gcodeFilePath)
36 print('removeGeneratedFiles deleted ' + gcodeFilePath)
38 if 'example_' not in gcodeFilePath:
39 os.remove(gcodeFilePath)
40 print('removeGeneratedFiles deleted ' + gcodeFilePath)
42 def removeGeneratedFiles():
43 'Remove generated files.'
44 csvFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['csv'])
45 for csvFilePath in csvFilePaths:
46 removeCSVFile(csvFilePath)
47 gcodeFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['gcode'])
48 for gcodeFilePath in gcodeFilePaths:
49 removeGcodeFile(gcodeFilePath)
50 svgFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['svg'])
51 for svgFilePath in svgFilePaths:
52 removeSVGFile(svgFilePath)
53 xmlFilePaths = archive.getFilesWithFileTypesWithoutWordsRecursively(['xml'])
54 for xmlFilePath in xmlFilePaths:
55 removeXMLFile(xmlFilePath)
56 archive.removeBackupFilesByTypes(['gcode', 'svg', 'xml'])
58 def removeSVGFile(svgFilePath):
60 if archive.getEndsWithList(svgFilePath, ['_bottom.svg', '_carve.svg', '_chop.svg', '_cleave.svg', '_scale.svg', '_vectorwrite.svg']):
61 os.remove(svgFilePath)
62 print('removeGeneratedFiles deleted ' + svgFilePath)
64 def removeXMLFile(xmlFilePath):
66 if archive.getEndsWithList(xmlFilePath, ['_interpret.xml']):
67 os.remove(xmlFilePath)
68 print('removeGeneratedFiles deleted ' + xmlFilePath)
71 'Remove the zip file, then generate a new one.zip -r reprap_python_beanshell * -x \*.pyc \*~'
72 zipName = 'reprap_python_beanshell'
73 zipNameExtension = zipName + '.zip'
74 if zipNameExtension in os.listdir(os.getcwd()):
75 os.remove(zipNameExtension)
76 shellCommand = 'zip -r %s * -x \*.pyc \*~' % zipName
77 if os.system(shellCommand) != 0:
78 print('Failed to execute the following command in removeZip in prepare.')
85 if __name__ == "__main__":