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 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 addPhotoImage( self, fileName, gridPosition ): 'Get a PhotoImage button, grid the button and increment the grid position.' photoImage = None try: photoImage = settings.Tkinter.PhotoImage( file = os.path.join( self.imagesDirectoryPath, fileName ), master = gridPosition.master ) except: print('Image %s was not found in the images directory, so a text button will be substituted.' % fileName ) untilDotFileName = archive.getUntilDot(fileName) self.photoImages[ untilDotFileName ] = photoImage return untilDotFileName
def addToProfileMenu( menu ): "Add a profile menu." settings.ToolDialog().addPluginToMenu(menu, archive.getUntilDot(archive.getSkeinforgePluginsPath('profile.py'))) menu.add_separator() directoryPath = skeinforge_profile.getPluginsDirectoryPath() pluginFileNames = skeinforge_profile.getPluginFileNames() craftTypeName = skeinforge_profile.getCraftTypeName() profileRadioVar = settings.Tkinter.StringVar() for pluginFileName in pluginFileNames: addSubmenus( craftTypeName, menu, pluginFileName, os.path.join( directoryPath, pluginFileName ), profileRadioVar )
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 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 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 addToCraftMenu( menu ): "Add a craft plugin menu." settings.ToolDialog().addPluginToMenu(menu, archive.getUntilDot(archive.getSkeinforgePluginsPath('craft.py'))) menu.add_separator() directoryPath = skeinforge_craft.getPluginsDirectoryPath() directoryFolders = settings.getFolders(directoryPath) pluginFileNames = skeinforge_craft.getPluginFileNames() for pluginFileName in pluginFileNames: pluginFolderName = pluginFileName + '_plugins' pluginPath = os.path.join( directoryPath, pluginFileName ) if pluginFolderName in directoryFolders: addSubmenus( menu, pluginFileName, os.path.join( directoryPath, pluginFolderName ), pluginPath ) else: settings.ToolDialog().addPluginToMenu( menu, pluginPath )
def addToCraftMenu( menu ): "Add a craft plugin menu." settings.ToolDialog().addPluginToMenu( menu, archive.getUntilDot( os.path.abspath( __file__ ) ) ) menu.add_separator() directoryPath = skeinforge_craft.getPluginsDirectoryPath() directoryFolders = settings.getFolders(directoryPath) pluginFileNames = skeinforge_craft.getPluginFileNames() for pluginFileName in pluginFileNames: pluginFolderName = pluginFileName + '_plugins' pluginPath = os.path.join( directoryPath, pluginFileName ) if pluginFolderName in directoryFolders: addSubmenus( menu, pluginFileName, os.path.join( directoryPath, pluginFolderName ), pluginPath ) else: settings.ToolDialog().addPluginToMenu( menu, pluginPath )
def addInitializationToOutput(self): "Add initialization gcode to the output." self.distanceFeedRate.addTagBracketedLine("format", "skeinforge gcode") absoluteFilePathUntilDot = archive.getUntilDot(archive.getCraftPluginsDirectoryPath("preface.py")) dateTodayString = date.today().isoformat().replace("-", ".")[2:] if ( absoluteFilePathUntilDot == "/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface" ): # is this script on Enrique's computer? archive.writeFileText(archive.getVersionFileName(), dateTodayString) versionText = archive.getFileText(archive.getVersionFileName()) self.distanceFeedRate.addTagBracketedLine("version", versionText) dateTimeTuple = datetime.now().timetuple() created = dateTodayString + "|%s:%s" % (dateTimeTuple[3], dateTimeTuple[4]) self.distanceFeedRate.addTagBracketedLine("created", created) self.distanceFeedRate.addLine("(<extruderInitialization>)") if self.repository.setPositioningToAbsolute.value: self.distanceFeedRate.addLine("G90 ;set positioning to absolute") # Set positioning to absolute. if self.repository.setUnitsToMillimeters.value: self.distanceFeedRate.addLine("G21 ;set units to millimeters") # Set units to millimeters. if self.repository.startAtHome.value: self.distanceFeedRate.addLine("G28 ;start at home") # Start at home. if self.repository.turnExtruderOffAtStartUp.value: self.distanceFeedRate.addLine("M103") # Turn extruder off. craftTypeName = skeinforge_profile.getCraftTypeName() self.distanceFeedRate.addTagBracketedLine("craftTypeName", craftTypeName) self.distanceFeedRate.addTagBracketedLine("decimalPlacesCarried", self.distanceFeedRate.decimalPlacesCarried) layerHeight = float(self.svgReader.sliceDictionary["layerHeight"]) self.distanceFeedRate.addTagRoundedLine("layerThickness", layerHeight) self.distanceFeedRate.addTagRoundedLine("layerHeight", layerHeight) if self.repository.meta.value: self.distanceFeedRate.addTagBracketedLine("meta", self.repository.meta.value) edgeWidth = float(self.svgReader.sliceDictionary["edgeWidth"]) self.distanceFeedRate.addTagRoundedLine("edgeWidth", edgeWidth) self.distanceFeedRate.addTagRoundedLine("perimeterWidth", edgeWidth) self.distanceFeedRate.addTagBracketedLine("profileName", skeinforge_profile.getProfileName(craftTypeName)) self.distanceFeedRate.addLine("(<settings>)") pluginFileNames = skeinforge_craft.getPluginFileNames() for pluginFileName in pluginFileNames: self.addToolSettingLines(pluginFileName) self.distanceFeedRate.addLine("(</settings>)") self.distanceFeedRate.addTagBracketedLine("timeStampPreface", strftime("%Y%m%d_%H%M%S")) procedureNames = self.svgReader.sliceDictionary["procedureName"].replace(",", " ").split() for procedureName in procedureNames: self.distanceFeedRate.addTagBracketedProcedure(procedureName) self.distanceFeedRate.addTagBracketedProcedure("preface") self.distanceFeedRate.addLine( "(</extruderInitialization>)" ) # Initialization is finished, extrusion is starting. self.distanceFeedRate.addLine("(<crafting>)") # Initialization is finished, crafting is starting.
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 addInitializationToOutput(self): "Add initialization gcode to the output." self.distanceFeedRate.addTagBracketedLine('format', 'skeinforge gcode') absoluteFilePathUntilDot = archive.getUntilDot(archive.getCraftPluginsDirectoryPath('preface.py')) dateTodayString = date.today().isoformat().replace('-', '.')[2 :] if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer? archive.writeFileText(archive.getVersionFileName(), dateTodayString) versionText = archive.getFileText(archive.getVersionFileName()) self.distanceFeedRate.addTagBracketedLine('version', versionText) dateTimeTuple = datetime.now().timetuple() created = dateTodayString + '|%s:%s' % (dateTimeTuple[3], dateTimeTuple[4]) self.distanceFeedRate.addTagBracketedLine('created', created) self.distanceFeedRate.addLine('(<extruderInitialization>)') if self.repository.setPositioningToAbsolute.value: self.distanceFeedRate.addLine('G90 ;set positioning to absolute') # Set positioning to absolute. if self.repository.setUnitsToMillimeters.value: self.distanceFeedRate.addLine('G21 ;set units to millimeters') # Set units to millimeters. if self.repository.startAtHome.value: self.distanceFeedRate.addLine('G28 ;start at home') # Start at home. if self.repository.resetExtruder.value: self.distanceFeedRate.addLine('G92 E0 ;reset extruder distance') # Start at home. if self.repository.turnExtruderOffAtStartUp.value: self.distanceFeedRate.addLine('M103') # Turn extruder off. craftTypeName = skeinforge_profile.getCraftTypeName() self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName) self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried) layerHeight = float(self.svgReader.sliceDictionary['layerHeight']) self.distanceFeedRate.addTagRoundedLine('layerThickness', layerHeight) self.distanceFeedRate.addTagRoundedLine('layerHeight', layerHeight) if self.repository.meta.value: self.distanceFeedRate.addTagBracketedLine('meta', self.repository.meta.value) edgeWidth = float(self.svgReader.sliceDictionary['edgeWidth']) self.distanceFeedRate.addTagRoundedLine('edgeWidth', edgeWidth) self.distanceFeedRate.addTagRoundedLine('perimeterWidth', edgeWidth) self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName(craftTypeName)) self.distanceFeedRate.addLine('(<settings>)') pluginFileNames = skeinforge_craft.getPluginFileNames() for pluginFileName in pluginFileNames: self.addToolSettingLines(pluginFileName) self.distanceFeedRate.addLine('(</settings>)') self.distanceFeedRate.addTagBracketedLine('timeStampPreface', strftime('%Y%m%d_%H%M%S')) procedureNames = self.svgReader.sliceDictionary['procedureName'].replace(',', ' ').split() for procedureName in procedureNames: self.distanceFeedRate.addTagBracketedProcedure(procedureName) self.distanceFeedRate.addTagBracketedProcedure('preface') self.distanceFeedRate.addLine('(</extruderInitialization>)') # Initialization is finished, extrusion is starting. self.distanceFeedRate.addLine('(<crafting>)') # Initialization is finished, crafting is starting.
def addInitializationToOutput(self): "Add initialization gcode to the output." self.distanceFeedRate.addTagBracketedLine('format', 'skeinforge gcode') absoluteFilePathUntilDot = archive.getUntilDot(archive.getCraftPluginsDirectoryPath('preface.py')) dateTodayString = date.today().isoformat().replace('-', '.')[2 :] if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer? archive.writeFileText(archive.getVersionFileName(), dateTodayString) versionText = archive.getFileText(archive.getVersionFileName()) self.distanceFeedRate.addTagBracketedLine('version', versionText) dateTimeTuple = datetime.now().timetuple() created = dateTodayString + '|%s:%s' % (dateTimeTuple[3], dateTimeTuple[4]) self.distanceFeedRate.addTagBracketedLine('created', created) self.distanceFeedRate.addLine('(<extruderInitialization>)') if self.repository.setPositioningToAbsolute.value: self.distanceFeedRate.addLine('G90 ;set positioning to absolute') # Set positioning to absolute. if self.repository.setUnitsToMillimeters.value: self.distanceFeedRate.addLine('G21 ;set units to millimeters') # Set units to millimeters. if self.repository.startAtHome.value: self.distanceFeedRate.addLine('G28 ;start at home') # Start at home. if self.repository.turnExtruderOffAtStartUp.value: self.distanceFeedRate.addLine('M103') # Turn extruder off. craftTypeName = skeinforge_profile.getCraftTypeName() self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName) self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried) layerHeight = float(self.svgReader.sliceDictionary['layerHeight']) self.distanceFeedRate.addTagRoundedLine('layerThickness', layerHeight) self.distanceFeedRate.addTagRoundedLine('layerHeight', layerHeight) if self.repository.meta.value: self.distanceFeedRate.addTagBracketedLine('meta', self.repository.meta.value) edgeWidth = float(self.svgReader.sliceDictionary['edgeWidth']) self.distanceFeedRate.addTagRoundedLine('edgeWidth', edgeWidth) self.distanceFeedRate.addTagRoundedLine('perimeterWidth', edgeWidth) self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName(craftTypeName)) self.distanceFeedRate.addLine('(<settings>)') pluginFileNames = skeinforge_craft.getPluginFileNames() for pluginFileName in pluginFileNames: self.addToolSettingLines(pluginFileName) self.distanceFeedRate.addLine('(</settings>)') self.distanceFeedRate.addTagBracketedLine('timeStampPreface', strftime('%Y%m%d_%H%M%S')) procedureNames = self.svgReader.sliceDictionary['procedureName'].replace(',', ' ').split() for procedureName in procedureNames: self.distanceFeedRate.addTagBracketedProcedure(procedureName) self.distanceFeedRate.addTagBracketedProcedure('preface') self.distanceFeedRate.addLine('(</extruderInitialization>)') # Initialization is finished, extrusion is starting. self.distanceFeedRate.addLine('(<crafting>)') # Initialization is finished, crafting is starting.
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)