Exemplo n.º 1
0
    def convert(self, filename):
        ok = False
        try:
            (event, xml) = scorer_to_usebio.convert(filename)
            self.save(event, xml)
            ok = True
        except IOError as err:
            logging.error("IO error: %s", err)
        except SyntaxError as err:
            logging.info(
                "The selected file '%s' does not look like a valid Scorer results file",
                filename)
            logging.error("Error details: %s", err)
        except scorer_to_usebio.InvalidResultsException as err:
            logging.error("Conversion error: %s", err)
            logging.info(
                "Please raise a support ticket, including the results file you were trying to convert"
            )
        except scorer_to_usebio.InvalidEventType as err:
            logging.error("Could not convert results: %s", err)
            logging.info(
                "Only match point scored events are supported at this time")

        if ok:
            self.deleteButton.setEnabled(True)
            self.statusBar().showMessage(
                ScorerConverter.status_text['converted_ok'])
        else:
            self.deleteButton.setEnabled(False)
            self.statusBar().showMessage(
                ScorerConverter.status_text['converted_error'])
Exemplo n.º 2
0
    def test(self):
        examples = []

        for root, dirs, files in os.walk(EXAMPLES_DIR):
            for file in files:
                path = os.path.join(root, file)
                if os.path.isfile(path) and path.endswith('.xml'):
                    examples.append(path)

        assert len(examples) > 0
        for path in examples:
            converted = scorer_to_usebio.convert(path, False)[1]
            expected = ET.parse(os.path.join(CONVERTED_DIR, os.path.basename(path)))
            converted_text = ET.tostring(converted.getroot())
            expected_text = ET.tostring(expected.getroot())
            fail_msg = "conversion mismatch for example file {}".format(os.path.normpath(path))
            self.assertEqual(converted_text, expected_text, msg=fail_msg)
Exemplo n.º 3
0
    def test(self):
        examples = []

        for root, dirs, files in os.walk(EXAMPLES_DIR):
            for file in files:
                path = os.path.join(root, file)
                if os.path.isfile(path) and path.endswith('.xml'):
                    examples.append(path)

        assert len(examples) > 0
        for path in examples:
            converted = scorer_to_usebio.convert(path, False)[1]
            expected = ET.parse(
                os.path.join(CONVERTED_DIR, os.path.basename(path)))
            converted_text = ET.tostring(converted.getroot())
            expected_text = ET.tostring(expected.getroot())
            fail_msg = "conversion mismatch for example file {}".format(
                os.path.normpath(path))
            self.assertEqual(converted_text, expected_text, msg=fail_msg)
Exemplo n.º 4
0
    def convert(self, filename):
        ok = False
        try:
            (event, xml) = scorer_to_usebio.convert(filename)
            self.save(event, xml)
            ok = True
        except IOError as err:
            logging.error("IO error: %s", err)
        except SyntaxError as err:
            logging.info("The selected file '%s' does not look like a valid Scorer results file", filename)
            logging.error("Error details: %s", err)
        except scorer_to_usebio.InvalidResultsException as err:
            logging.error("Conversion error: %s", err)
            logging.info("Please raise a support ticket, including the results file you were trying to convert")
        except scorer_to_usebio.InvalidEventType as err:
            logging.error("Could not convert results: %s", err)
            logging.info("Only match point scored events are supported at this time")

        if ok:
            self.deleteButton.setEnabled(True)
            self.statusBar().showMessage(ScorerConverter.status_text['converted_ok'])
        else:
            self.deleteButton.setEnabled(False)
            self.statusBar().showMessage(ScorerConverter.status_text['converted_error'])