def asXml(self): line = self.getSourceReference().getLineNumber() result = TreeXML.Element("node", kind=self.__class__.__name__, line="%s" % line) compat_line = self.getCompatibleSourceReference().getLineNumber() if compat_line != line: result.attrib["compat_line"] = str(compat_line) for key, value in iterItems(self.getDetailsForDisplay()): result.set(key, str(value)) for name, children in self.getVisitableNodesNamed(): role = TreeXML.Element("role", name=name) result.append(role) if children is None: role.attrib["type"] = "none" elif type(children) not in (list, tuple): role.append(children.asXml()) else: role.attrib["type"] = "list" for child in children: role.append(child.asXml()) return result
def asXml(self): result = TreeXML.Element("node", kind=self.__class__.__name__, line="%s" % self.getSourceReference().getLineNumber()) for key, value in iterItems(self.getDetails()): value = str(value) if value.startswith("<") and value.endswith(">"): value = value[1:-1] result.set(key, str(value)) for name, children in self.getVisitableNodesNamed(): if type(children) not in (list, tuple): children = (children, ) role = TreeXML.Element("role", name=name) result.append(role) for child in children: if child is not None: role.append(child.asXml()) return result
def addResourceToFile(self, filename): addResourceToFile( target_filename=filename, data=TreeXML.toBytes(self.tree), resource_kind=RT_MANIFEST, res_name=1, lang_id=0, )
def addResourceToFile(self, filename, logger): manifest_data = TreeXML.toBytes(self.tree, indent=False) addResourceToFile( target_filename=filename, data=manifest_data, resource_kind=RT_MANIFEST, res_name=1, lang_id=0, logger=logger, )
def writeCompilationReport(report_filename): active_modules_info = getModuleInclusionInfos() root = TreeXML.Element("nuitka-compilation-report") for module in getDoneModules(): active_module_info = active_modules_info[module] root.append( TreeXML.Element( "module", name=module.getFullName(), kind=module.__class__.__name__, reason=active_module_info.reason, )) putTextFileContents(filename=report_filename, contents=TreeXML.toString(root)) general.info("Compilation report in file %r." % report_filename)
def writeCompilationReport(report_filename): active_modules_info = getModuleInclusionInfos() root = TreeXML.Element("nuitka-compilation-report") for module in getDoneModules(): active_module_info = active_modules_info[module] root.append( TreeXML.Element( "module", name=module.getFullName(), kind=module.__class__.__name__, reason=active_module_info.reason, )) for included_datafile in getIncludedDataFiles(): if included_datafile.kind == "data_file": root.append( TreeXML.Element( "data_file", name=included_datafile.dest_path, source=included_datafile.source_path, reason=included_datafile.reason, tags=",".join(included_datafile.tags), )) elif included_datafile.kind == "data_blob": root.append( TreeXML.Element( "data_blob", name=included_datafile.dest_path, reason=included_datafile.reason, tags=",".join(included_datafile.tags), )) putTextFileContents(filename=report_filename, contents=TreeXML.toString(root)) general.info("Compilation report in file %r." % report_filename)
def asXmlText(self): xml = self.asXml() return TreeXML.toString(xml)
def __init__(self, template): self.tree = TreeXML.fromString(template)