def parse()

in scripts/metric_reporter/parser/junit_xml_parser.py [0:0]


    def parse(self, artifact_file_names: list[str]) -> list[JUnitXmlGroup]:
        """Parse JUnit XML content from the specified directory.

        Args:
            artifact_file_names (str): Paths of the JUnit XML test files.

        Returns:
            list[JUnitXmlGroup]: A list of parsed JUnit XML files grouped by repository, workflow
                                 and test suite.

        Raises:
            ParserError: If there is an error reading or parsing the XML files.
        """
        junit_xml_groups: list[JUnitXmlGroup] = []
        for artifact_file_name in artifact_file_names:
            self.logger.info(f"Parsing {artifact_file_name}")
            file: ArtifactFile = self._parse_artifact_file_name(artifact_file_name)
            junit_xml: JUnitXmlJobTestSuites = self._get_junit_xml(file, junit_xml_groups)
            try:
                test_suites: JUnitXmlTestSuites = self._parse_test_suites(
                    file.repository, file.name
                )
                junit_xml.test_suites.append(test_suites)
            except ValidationError as error:
                error_msg: str = f"Unexpected value or schema in file {artifact_file_name}"
                self.logger.error(error_msg, exc_info=error)
                raise ParserError(error_msg) from error
        return junit_xml_groups