当前位置: 首页>>代码示例>>Python>>正文


Python Extractor.extract_data方法代码示例

本文整理汇总了Python中extractor.Extractor.extract_data方法的典型用法代码示例。如果您正苦于以下问题:Python Extractor.extract_data方法的具体用法?Python Extractor.extract_data怎么用?Python Extractor.extract_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在extractor.Extractor的用法示例。


在下文中一共展示了Extractor.extract_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ExtractorTest

# 需要导入模块: from extractor import Extractor [as 别名]
# 或者: from extractor.Extractor import extract_data [as 别名]
class ExtractorTest(unittest.TestCase):

    def setUp(self):
        example = "LOQ75625Team LOQ            49% blend std 8mm       21-JUN-2000 12:55:23    30.0"
        self.extractor = Extractor()
        self.extractor.extract_data(example)

    def tearDown(self):
        pass

    def test_extract_valid_instrument_name(self):
        self.assertEqual("LOQ", self.extractor.instrumentname)

    def test_extract_valid_run_number(self):
        self.assertEqual("75625", self.extractor.runnumber)

    def test_extract_valid_run_username(self):
        self.assertEqual("Team LOQ", self.extractor.username)

    def test_extract_valid_run_experimenttitle(self):
        self.assertEqual("49% blend std 8mm", self.extractor.experimenttitle)

    def test_extract_valid_run_startdate(self):
        self.assertEqual("21-JUN-2000", self.extractor.startdate)

    def test_extract_valid_run_starttime(self):
        self.assertEqual("12:55:23", self.extractor.starttime)

    def test_extract_valid_run_charge(self):
        self.assertEqual("30.0", self.extractor.charge)
开发者ID:ISISComputingGroup,项目名称:VmsJournalFileConverter,代码行数:32,代码来源:extractor_test.py

示例2: ConverterTest

# 需要导入模块: from extractor import Extractor [as 别名]
# 或者: from extractor.Extractor import extract_data [as 别名]
class ConverterTest(unittest.TestCase):

    def setUp(self):
        self.loader = FileLoader()
        self.converter = Converter()
        self.extractor = Extractor()
        self.loader.load_file("logs_old/JOURNAL00.TXT")
        self.converter.read_entries(self.loader.lines)

    def test_read_all_lines(self):
        self.assertTrue(len(self.converter.entries) > 0)
        self.assertEqual(len(self.converter.entries), len(self.loader.lines))

    def test_converted_entries_are_valid(self):
        for i in xrange(len(self.loader.lines)):
            self.extractor.extract_data(self.loader.lines[i])
            self.assertEqual(self.converter.entries[i].instrumentname, self.extractor.instrumentname)
            self.assertEqual(self.converter.entries[i].runnumber, self.extractor.runnumber)
            self.assertEqual(self.converter.entries[i].username, self.extractor.username)
            self.assertEqual(self.converter.entries[i].experimenttitle, self.extractor.experimenttitle)
            self.assertEqual(self.converter.entries[i].startdate, self.extractor.startdate)
            self.assertEqual(self.converter.entries[i].starttime, self.extractor.starttime)
            self.assertEqual(self.converter.entries[i].charge, self.extractor.charge)
开发者ID:ISISComputingGroup,项目名称:VmsJournalFileConverter,代码行数:25,代码来源:converter_test.py

示例3: XMLOutputterTest

# 需要导入模块: from extractor import Extractor [as 别名]
# 或者: from extractor.Extractor import extract_data [as 别名]
class XMLOutputterTest(unittest.TestCase):

    def setUp(self):
        # open and parse model xml file
        self.fmodel = open("logs_new/model_log.xml")
        self.model_tree = ET.parse(self.fmodel)
        self.model_root = self.model_tree.getroot()
        # create sample experiment data
        example = "LOQ75625Team LOQ            49% blend std 8mm       21-JUN-2000 12:55:23    30.0"
        self.extractor = Extractor()
        self.extractor.extract_data(example)
        self.maxDiff = None

        self.xml_out = XMLOutputter("testlog")
        self.xml_out.write_line(self.extractor)

    def test_instrumentname_matches_model(self):
        instrumentname = self.xml_out.get_xml().findall("./NXentry/instrument_name")[0].text
        self.assertEqual("LOQ", instrumentname)

    def test_instrumentname_attribute_matches_model(self):
        instrumentname = self.xml_out.get_xml().findall("./NXentry/instrument_name")[0]
        self.assertEqual("NX_CHAR[3]", instrumentname.get("NAPItype"))

    def test_username_matches_model(self):
        username = self.xml_out.get_xml().findall("./NXentry/user_name")[0].text
        self.assertEqual("Team LOQ", username)

    def test_username_attribute_matches_model(self):
        username = self.xml_out.get_xml().findall("./NXentry/user_name")[0]
        self.assertEqual("NX_CHAR[8]", username.get("NAPItype"))

    def test_experimenttitle_matches_model(self):
        experimenttitle = self.xml_out.get_xml().findall("./NXentry/title")[0].text
        self.assertEqual("49% blend std 8mm", experimenttitle)

    def test_experimenttitle_attribute_matches_model(self):
        experimenttitle = self.xml_out.get_xml().findall("./NXentry/title")[0]
        self.assertEqual("NX_CHAR[17]", experimenttitle.get("NAPItype"))

    def test_runnumber_matches_model(self):
        runnumber = self.xml_out.get_xml().findall("./NXentry/run_number")[0].text
        self.assertEqual("75625", runnumber)

    def test_runnumber_attribute_matches_model(self):
        runnumber = self.xml_out.get_xml().findall("./NXentry/run_number")[0]
        self.assertEqual("NX_INT32", runnumber.get("NAPItype"))

    def test_starttime_matches_model(self):
        starttime = self.xml_out.get_xml().findall("./NXentry/start_time")[0].text
        self.assertEqual("2000-06-21T12:55:23", starttime)

    def test_starttime_attribute_matches_model(self):
        runnumber = self.xml_out.get_xml().findall("./NXentry/start_time")[0]
        self.assertEqual("NX_CHAR[19]", runnumber.get("NAPItype"))

    def test_charge_matches_model(self):
        charge = self.xml_out.get_xml().findall("./NXentry/proton_charge")[0].text
        self.assertEqual("30.0", charge)

    def test_charge_attribute_matches_model(self):
        charge = self.xml_out.get_xml().findall("./NXentry/proton_charge")[0]
        self.assertEqual("NX_FLOAT32", charge.get("NAPItype"))

    def test_is_outputting(self):
        self.xml_out.output_to_file()
        newlog = open("logs_new/testlog.xml", "r")
        self.assertTrue(len(newlog.readlines()) > 1)
        newlog.close()
开发者ID:ISISComputingGroup,项目名称:VmsJournalFileConverter,代码行数:71,代码来源:xml_outputter_test.py


注:本文中的extractor.Extractor.extract_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。