Ejemplo n.º 1
0
 def get_mission(hdr):
     """
     Return the "Mission" field for a single GIPP file.
     :param hdr: The full path to the HDR file
     :return:
     """
     from Common import XMLTools
     return XMLTools.get_single_xpath(hdr, "./Fixed_Header/Mission")
Ejemplo n.º 2
0
 def test_write_and_get_xpath(self):
     from xml.etree import ElementTree
     from Common import FileSystem
     file_path = os.path.join(self.root, "dummy_xml.xml")
     mission_expected = "DummyMission"
     xpath = "./Fixed_Header/Mission"
     root = ElementTree.Element("Earth_Explorer_Header")
     sub = ElementTree.SubElement(root, "Fixed_Header")
     ElementTree.SubElement(sub, "Mission").text = mission_expected
     ElementTree.SubElement(root, "Variable_Header")
     XMLTools.write_xml(root, file_path)
     self.assertTrue(os.path.exists(file_path))
     mission_calculated = XMLTools.get_xpath(file_path, xpath)[0].text
     mission_calculated_2 = XMLTools.get_single_xpath(file_path, xpath)
     self.assertEqual(mission_calculated, mission_expected)
     self.assertEqual(mission_expected, mission_calculated_2)
     FileSystem.remove_file(file_path)