def xml_processor(p: Processor, registry: PartialRetrievalDictionary, p_map: Dict[str, Processor]): """ Return the XML of a processor Recursive into children :param p: :return: """ def xml_interface(iface: Factor): """ :param iface: :return: """ s = f'<{iface.name} type="{iface.taxon.name}" sphere="{iface.sphere}" ' \ f'roegen_type="{iface.roegen_type}" orientation="{iface.orientation}" ' \ f'opposite_processor_type="{iface.opposite_processor_type}" />' if case_sensitive: return s else: return s.lower() children = p.children(registry) full_name = p.full_hierarchy_names(registry)[0] if case_sensitive: p_map[full_name] = p else: p_map[full_name.lower()] = p s = f""" <{p.name} fullname="{full_name}" level="{p.level}" system="{p.processor_system}" subsystem="{p.subsystem_type}" functional="{"true" if strcmp(p.functional_or_structural, "Functional") else "false"}" > <interfaces> {chr(10).join([xml_interface(f) for f in p.factors])} </interfaces> {chr(10).join([xml_processor(c, registry, p_map) for c in children])} </{p.name}>""" if case_sensitive: return s else: return s.lower()
def get_processor_unique_label(p: Processor, reg: PartialRetrievalDictionary): return p.full_hierarchy_names(reg)[0]