def processXMLElement(xmlElement): "Process the xml element." fileName = evaluate.getEvaluatedValue('file', xmlElement ) if fileName == None: return parserFileName = xmlElement.getRoot().parser.fileName absoluteFileName = archive.getAbsoluteFolderPath( parserFileName, fileName ) xmlText = '' if fileName.endswith('.xml'): xmlText = archive.getFileText( absoluteFileName ) else: xmlText = getXMLFromCarvingFileName( absoluteFileName ) if xmlText == '': print('The file %s could not be found in the folder which the fabmetheus xml file is in.' % fileName ) return if '_importname' in xmlElement.attributeDictionary: xmlElement.importName = xmlElement.attributeDictionary['_importname'] else: xmlElement.importName = archive.getUntilDot(fileName) xmlElement.attributeDictionary['_importname'] = xmlElement.importName XMLSimpleReader( parserFileName, xmlElement, xmlText ) originalChildren = xmlElement.children[:] xmlElement.children = [] for child in originalChildren: for subchild in child.children: subchild.setParentAddToChildren(xmlElement) for attributeDictionaryKey in child.attributeDictionary.keys(): if attributeDictionaryKey != 'version': xmlElement.attributeDictionary[attributeDictionaryKey] = child.attributeDictionary[attributeDictionaryKey] group.processShape( group.Group, xmlElement)
def getGeometryOutput(elementNode): 'Get vector3 vertexes from attribute dictionary.' derivation = HeightmapDerivation(elementNode) heightGrid = derivation.heightGrid if derivation.fileName != '': heightGrid = getHeightGrid(archive.getAbsoluteFolderPath(elementNode.getOwnerDocument().fileName, derivation.fileName)) return getGeometryOutputByHeightGrid(derivation, elementNode, heightGrid)
def writeHypertext(): 'Run pydoc, then read, write and delete each of the files.' shellCommand = 'pydoc -w ./' commandResult = os.system(shellCommand) if commandResult != 0: print( 'Failed to execute the following command in writeHypertext in docwrap.' ) print(shellCommand) hypertextFiles = archive.getFilesWithFileTypeWithoutWords('html') if len(hypertextFiles) <= 0: print('Failed to find any help files in writeHypertext in docwrap.') return documentDirectoryPath = archive.getAbsoluteFolderPath( hypertextFiles[0], 'documentation') removeFilesInDirectory(documentDirectoryPath) sortedReplaceFiles = [] for hypertextFile in hypertextFiles: sortedReplaceFiles.append(hypertextFile.replace('.html', '. html')) sortedReplaceFiles.sort() hypertextFiles = [] for sortedReplaceFile in sortedReplaceFiles: hypertextFiles.append(sortedReplaceFile.replace('. html', '.html')) transferredFileNames = [] for hypertextFileIndex in xrange(len(hypertextFiles)): readWriteDeleteHypertextHelp(documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames) for transferredFileNameIndex in xrange(len(transferredFileNames)): readWriteNavigationHelp(documentDirectoryPath, transferredFileNameIndex, transferredFileNames) writeContentsFile(documentDirectoryPath, transferredFileNames) print('%s files were wrapped.' % len(transferredFileNames))
def processXMLElement(xmlElement): "Process the xml element." fileName = evaluate.getEvaluatedValue('file', xmlElement) if fileName == None: return parserFileName = xmlElement.getRoot().parser.fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName) xmlText = '' if fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) if xmlText == '': print( 'The file %s could not be found in the folder which the fabmetheus xml file is in.' % fileName) return if '_importname' in xmlElement.attributeDictionary: xmlElement.importName = xmlElement.attributeDictionary['_importname'] else: xmlElement.importName = archive.getUntilDot(fileName) xmlElement.attributeDictionary['_importname'] = xmlElement.importName XMLSimpleReader(parserFileName, xmlElement, xmlText) originalChildren = xmlElement.children[:] xmlElement.children = [] for child in originalChildren: for subchild in child.children: subchild.setParentAddToChildren(xmlElement) for attributeDictionaryKey in child.attributeDictionary.keys(): if attributeDictionaryKey != 'version': xmlElement.attributeDictionary[ attributeDictionaryKey] = child.attributeDictionary[ attributeDictionaryKey] group.processShape(group.Group, xmlElement)
def getGeometryOutput(xmlElement): 'Get vector3 vertexes from attribute dictionary.' derivation = HeightmapDerivation(xmlElement) heightGrid = derivation.heightGrid if derivation.fileName != '': heightGrid = getHeightGrid(archive.getAbsoluteFolderPath(xmlElement.getParser().fileName, derivation.fileName)) return getGeometryOutputByHeightGrid(derivation, heightGrid, xmlElement)
def writeHypertext(): 'Run pydoc, then read, write and delete each of the files.' shellCommand = 'pydoc -w ./' commandResult = os.system(shellCommand) if commandResult != 0: print('Failed to execute the following command in writeHypertext in docwrap.') print( shellCommand ) hypertextFiles = archive.getFilesWithFileTypeWithoutWords('html') if len( hypertextFiles ) <= 0: print('Failed to find any help files in writeHypertext in docwrap.') return documentDirectoryPath = archive.getAbsoluteFolderPath( hypertextFiles[0], 'documentation') removeFilesInDirectory(documentDirectoryPath) sortedReplaceFiles = [] for hypertextFile in hypertextFiles: sortedReplaceFiles.append(hypertextFile.replace('.html', '. html')) sortedReplaceFiles.sort() hypertextFiles = [] for sortedReplaceFile in sortedReplaceFiles: hypertextFiles.append(sortedReplaceFile.replace('. html', '.html')) transferredFileNames = [] for hypertextFileIndex in xrange(len(hypertextFiles)): readWriteDeleteHypertextHelp(documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames) for transferredFileNameIndex in xrange(len(transferredFileNames)): readWriteNavigationHelp(documentDirectoryPath, transferredFileNameIndex, transferredFileNames) writeContentsFile(documentDirectoryPath, transferredFileNames) print('%s files were wrapped.' % len(transferredFileNames))
def getGeometryOutput(xmlElement): 'Get vector3 vertexes from attribute dictionary.' derivation = HeightmapDerivation(xmlElement) heightGrid = derivation.heightGrid if derivation.fileName != '': heightGrid = getHeightGrid( archive.getAbsoluteFolderPath(xmlElement.getParser().fileName, derivation.fileName)) return getGeometryOutputByHeightGrid(derivation, heightGrid, xmlElement)
def addCanvasMenuRootScrollSkein(self, repository, skein, suffix, title): 'Add the canvas, menu bar, scroll bar, skein panes, tableau repository, root and skein.' self.imagesDirectoryPath = archive.getFabmetheusUtilitiesPath('images') self.movementTextID = None self.mouseInstantButtons = [] self.photoImages = {} self.repository = repository self.root = settings.Tkinter.Tk() self.gridPosition = settings.GridVertical(0, 1) self.gridPosition.master = self.root self.highlightThickness = 3 self.root.title(os.path.basename(skein.fileName) + ' - ' + title) self.rulingExtent = 24 self.rulingTargetSeparation = 150.0 self.screenSize = skein.screenSize self.skein = skein self.skeinPanes = skein.skeinPanes self.suffix = suffix self.timerID = None repository.animationSlideShowRate.value = max(repository.animationSlideShowRate.value, 0.01) repository.animationSlideShowRate.value = min(repository.animationSlideShowRate.value, 85.0) repository.drawArrows.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.goAroundExtruderOffTravel.setUpdateFunction(self.setWindowToDisplaySavePhoenixUpdate) repository.layerExtraSpan.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.showGcode.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.widthOfSelectionThread.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.widthOfTravelThread.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.window = self for menuRadio in repository.mouseMode.menuRadios: fileName = menuRadio.name.lower() fileName = fileName.replace(' ', '_') + '.ppm' menuRadio.mouseButton = self.getPhotoButtonGridIncrement(menuRadio.invoke, fileName, self.gridPosition) self.gridPosition = settings.GridHorizontal(2, 99) self.gridPosition.master = self.root self.gcodeStringVar = settings.Tkinter.StringVar(self.root) self.gcodeLabel = settings.Tkinter.Label(self.root, anchor = settings.Tkinter.W, textvariable = self.gcodeStringVar) self.gcodeLabel.grid(row = 0, column = 5, columnspan = 93, sticky = settings.Tkinter.W) from fabmetheus_utilities.hidden_scrollbar import HiddenScrollbar self.xScrollbar = HiddenScrollbar(self.root, orient = settings.Tkinter.HORIZONTAL) self.xScrollbar.grid(row = 98, column = 2, columnspan = 96, sticky = settings.Tkinter.E + settings.Tkinter.W) self.yScrollbar = HiddenScrollbar(self.root) self.yScrollbar.grid(row = 2, rowspan = 96, column = 99, sticky = settings.Tkinter.N + settings.Tkinter.S) self.canvasHeight = self.root.winfo_screenheight() - repository.screenVerticalInset.value self.canvasWidth = self.root.winfo_screenwidth() - repository.screenHorizontalInset.value scrollRegionBoundingBox = (0, 0, int(skein.screenSize.real), int(skein.screenSize.imag)) self.canvas = settings.Tkinter.Canvas(self.root, highlightthickness = self.highlightThickness, width = self.canvasWidth, height = self.canvasHeight, scrollregion = scrollRegionBoundingBox) self.canvas.grid(row = 2, rowspan = 96, column = 2, columnspan = 96, sticky = settings.Tkinter.E + settings.Tkinter.W + settings.Tkinter.N + settings.Tkinter.S) self.fileHelpMenuBar = settings.FileHelpMenuBar(self.root) self.exportMenu = settings.Tkinter.Menu(self.fileHelpMenuBar.fileMenu, tearoff = 0) self.fileHelpMenuBar.fileMenu.add_cascade(label = 'Export', menu = self.exportMenu, underline = 0) exportCanvasPluginsFolderPath = archive.getAbsoluteFolderPath(os.path.dirname(__file__), 'export_canvas_plugins') exportCanvasPluginFileNames = archive.getPluginFileNamesFromDirectoryPath(exportCanvasPluginsFolderPath) for exportCanvasPluginFileName in exportCanvasPluginFileNames: ExportCanvasDialog().addPluginToMenu(self.canvas, skein.fileName, self.exportMenu, exportCanvasPluginFileName, suffix) self.fileHelpMenuBar.fileMenu.add_separator() self.fileHelpMenuBar.completeMenu(self.close, repository, self.save, self)
def processXMLElement(xmlElement): 'Process the xml element.' fileName = evaluate.getEvaluatedValue('file', xmlElement) if fileName == None: return parserFileName = xmlElement.getRoot().parser.fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName) absoluteFileName = os.path.abspath(absoluteFileName) if 'models/' not in absoluteFileName: print( 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:' ) print(xmlElement) print('For which the absolute file path is:') print(absoluteFileName) print( 'The import tool can only read a file which has models/ in the file path.' ) print( 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.' ) return xmlText = '' if fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print('The import tool is opening the file:') print(absoluteFileName) if xmlText == '': print( 'The file %s could not be found by processXMLElement in import.' % fileName) return if '_importName' in xmlElement.attributeDictionary: xmlElement.importName = xmlElement.attributeDictionary['_importName'] else: xmlElement.importName = archive.getUntilDot(fileName) if evaluate.getEvaluatedBooleanDefault(True, 'basename', xmlElement): xmlElement.importName = os.path.basename(xmlElement.importName) xmlElement.attributeDictionary['_importName'] = xmlElement.importName importXMLElement = xml_simple_reader.XMLElement() xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement, xmlText) for child in importXMLElement.children: child.copyXMLChildren('', xmlElement) euclidean.removeElementsFromDictionary(child.attributeDictionary, ['id', 'name']) xmlElement.attributeDictionary.update(child.attributeDictionary) if evaluate.getEvaluatedBooleanDefault(False, 'overwriteRoot', xmlElement): xmlElement.getRoot().attributeDictionary.update( child.attributeDictionary) group.processShape(group.Group, xmlElement)
def processXMLElementByDerivation(derivation, xmlElement): 'Process the xml element by derivation.' if derivation == None: derivation = ImportDerivation(xmlElement) if derivation.fileName == None: return parserFileName = xmlElement.getParser().fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, derivation.fileName) if 'models/' not in absoluteFileName: print( 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:' ) print(xmlElement) print('For which the absolute file path is:') print(absoluteFileName) print( 'The import tool can only read a file which has models/ in the file path.' ) print( 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.' ) return xmlText = '' if derivation.fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print('The import tool is opening the file:') print(absoluteFileName) if xmlText == '': print( 'The file %s could not be found by processXMLElement in import.' % derivation.fileName) return if derivation.importName == None: xmlElement.importName = archive.getUntilDot(derivation.fileName) if derivation.basename: xmlElement.importName = os.path.basename(xmlElement.importName) xmlElement.attributeDictionary['_importName'] = xmlElement.importName else: xmlElement.importName = derivation.importName importXMLElement = xml_simple_reader.XMLElement() xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement, xmlText) for child in importXMLElement.children: child.copyXMLChildren('', xmlElement) evaluate.removeIdentifiersFromDictionary(child.attributeDictionary) xmlElement.attributeDictionary.update(child.attributeDictionary) if derivation.overwriteRoot: xmlElement.getRoot().attributeDictionary.update( child.attributeDictionary) xmlElement.className = 'group' evaluate.processArchivable(group.Group, xmlElement)
def processXMLElementByDerivation(derivation, xmlElement): """Process the xml element by derivation.""" if derivation is None: derivation = ImportDerivation(xmlElement) if derivation.fileName is None: return parserFileName = xmlElement.getParser().fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, derivation.fileName) if 'models/' not in absoluteFileName: print( 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:' ) print(xmlElement) print('For which the absolute file path is:') print(absoluteFileName) print( 'The import tool can only read a file which has models/ in the file path.' ) print( 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.' ) return xmlText = '' if derivation.fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print('The import tool is opening the file:') print(absoluteFileName) if xmlText == '': print('The file %s could not be found by processXMLElement in import.' % derivation.fileName) return if derivation.importName is None: xmlElement.importName = archive.getUntilDot(derivation.fileName) if derivation.basename: xmlElement.importName = os.path.basename(xmlElement.importName) xmlElement.attributeDictionary['_importName'] = xmlElement.importName else: xmlElement.importName = derivation.importName importXMLElement = xml_simple_reader.XMLElement() xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement, xmlText) for child in importXMLElement.children: child.copyXMLChildren('', xmlElement) evaluate.removeIdentifiersFromDictionary(child.attributeDictionary) xmlElement.attributeDictionary.update(child.attributeDictionary) if derivation.overwriteRoot: xmlElement.getRoot().attributeDictionary.update( child.attributeDictionary) xmlElement.className = 'group' evaluate.processArchivable(group.Group, xmlElement)
def display(self): 'Display the export canvas repository dialog.' for repositoryDialog in settings.globalRepositoryDialogListTable: if repositoryDialog.repository.lowerName == self.name: repositoryDialog.setCanvasFileNameSuffix( self.canvas, self.skein.fileName, self.suffix ) settings.liftRepositoryDialogs( settings.globalRepositoryDialogListTable[ repositoryDialog ] ) return exportCanvasPluginsFolderPath = archive.getAbsoluteFolderPath( os.path.dirname(__file__), 'export_canvas_plugins') pluginModule = archive.getModuleWithDirectoryPath( exportCanvasPluginsFolderPath, self.name ) if pluginModule == None: return None pluginRepository = pluginModule.getNewRepository() pluginRepository.setCanvasFileNameSuffix( self.canvas, self.fileName, self.suffix ) settings.getDisplayedDialogFromConstructor( pluginRepository )
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = ImportDerivation(elementNode) if derivation.fileName == None: return parserFileName = elementNode.getOwnerDocument().fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, derivation.fileName) if 'models/' not in absoluteFileName: print( 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:' ) print(elementNode) print('For which the absolute file path is:') print(absoluteFileName) print( 'The import tool can only read a file which has models/ in the file path.' ) print( 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.' ) return xmlText = '' if derivation.fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print('The import tool is opening the file:') print(absoluteFileName) if xmlText == '': print( 'The file %s could not be found by processElementNode in import.' % derivation.fileName) return if derivation.importName == None: elementNode.attributes['_importName'] = archive.getUntilDot( derivation.fileName) if derivation.basename: elementNode.attributes['_importName'] = os.path.basename( elementNode.attributes['_importName']) xml_simple_reader.createAppendByText(elementNode, xmlText) if derivation.appendDocumentElement: appendAttributes(elementNode, elementNode.getDocumentElement()) if derivation.appendElement: appendAttributes(elementNode, elementNode) elementNode.localName = 'group' evaluate.processArchivable(group.Group, elementNode)
def processXMLElement(xmlElement): 'Process the xml element.' fileName = evaluate.getEvaluatedValue('file', xmlElement ) if fileName == None: return parserFileName = xmlElement.getRoot().parser.fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, fileName) absoluteFileName = os.path.abspath(absoluteFileName) if 'models/' not in absoluteFileName: print('Warning, models/ was not in the absolute file path, so for security nothing will be done for:') print(xmlElement) print('For which the absolute file path is:') print(absoluteFileName) print('The import tool can only read a file which has models/ in the file path.') print('To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.') return xmlText = '' if fileName.endswith('.xml'): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print('The import tool is opening the file:') print(absoluteFileName) if xmlText == '': print('The file %s could not be found by processXMLElement in import.' % fileName) return if '_importName' in xmlElement.attributeDictionary: xmlElement.importName = xmlElement.attributeDictionary['_importName'] else: xmlElement.importName = archive.getUntilDot(fileName) if evaluate.getEvaluatedBooleanDefault(True, 'basename', xmlElement): xmlElement.importName = os.path.basename(xmlElement.importName) xmlElement.attributeDictionary['_importName'] = xmlElement.importName importXMLElement = xml_simple_reader.XMLElement() xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement, xmlText) for child in importXMLElement.children: child.copyXMLChildren('', xmlElement) euclidean.removeElementsFromDictionary(child.attributeDictionary, ['id', 'name']) xmlElement.attributeDictionary.update(child.attributeDictionary) if evaluate.getEvaluatedBooleanDefault(False, 'overwriteRoot', xmlElement): xmlElement.getRoot().attributeDictionary.update(child.attributeDictionary) group.processShape(group.Group, xmlElement)
def processElementNodeByDerivation(derivation, elementNode): "Process the xml element by derivation." if derivation == None: derivation = ImportDerivation(elementNode) if derivation.fileName == None: return parserFileName = elementNode.getOwnerDocument().fileName absoluteFileName = archive.getAbsoluteFolderPath(parserFileName, derivation.fileName) if "models/" not in absoluteFileName: print("Warning, models/ was not in the absolute file path, so for security nothing will be done for:") print(elementNode) print("For which the absolute file path is:") print(absoluteFileName) print("The import tool can only read a file which has models/ in the file path.") print( "To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree." ) return xmlText = "" if derivation.fileName.endswith(".xml"): xmlText = archive.getFileText(absoluteFileName) else: xmlText = getXMLFromCarvingFileName(absoluteFileName) print("The import tool is opening the file:") print(absoluteFileName) if xmlText == "": print("The file %s could not be found by processElementNode in import." % derivation.fileName) return if derivation.importName == None: elementNode.attributes["_importName"] = archive.getUntilDot(derivation.fileName) if derivation.basename: elementNode.attributes["_importName"] = os.path.basename(elementNode.attributes["_importName"]) xml_simple_reader.createAppendByText(elementNode, xmlText) if derivation.appendDocumentElement: appendAttributes(elementNode, elementNode.getDocumentElement()) if derivation.appendElement: appendAttributes(elementNode, elementNode) elementNode.localName = "group" evaluate.processArchivable(group.Group, elementNode)
def getPluginsDirectoryPath(): "Get the plugins directory path." return archive.getAbsoluteFolderPath( os.path.dirname( __file__ ), os.path.join('skeinforge_plugins', 'craft_plugins') )
def getPluginsDirectoryPath(): "Get the plugins directory path." return archive.getAbsoluteFolderPath( os.path.dirname(__file__), os.path.join('skeinforge_plugins', 'analyze_plugins') )