Loading pygriffin/isoxml_reader.py 0 → 100644 +23 −0 Original line number Diff line number Diff line import sys from xml.etree import ElementTree as ET def parse_isoxml(isoxml_file): tree = ET.parse(isoxml_file) root = tree.getroot() out_str = "" # find all "Isotope" elements isotopes = list(root.iter('Isotope')) out_str += f'Found {len(isotopes)} isotopes in the ISOXML:\n' for isotope in isotopes: out_str += f"\t{isotope.attrib['Name']}\n" return out_str if __name__ == '__main__': print(f'Parsing XML file {sys.argv[1]}...') print(parse_isoxml(sys.argv[1])) Loading
pygriffin/isoxml_reader.py 0 → 100644 +23 −0 Original line number Diff line number Diff line import sys from xml.etree import ElementTree as ET def parse_isoxml(isoxml_file): tree = ET.parse(isoxml_file) root = tree.getroot() out_str = "" # find all "Isotope" elements isotopes = list(root.iter('Isotope')) out_str += f'Found {len(isotopes)} isotopes in the ISOXML:\n' for isotope in isotopes: out_str += f"\t{isotope.attrib['Name']}\n" return out_str if __name__ == '__main__': print(f'Parsing XML file {sys.argv[1]}...') print(parse_isoxml(sys.argv[1]))