Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
121 changed files
with
25,257 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import pathlib | ||
from typing import Iterable, Callable | ||
|
||
from lxml import etree | ||
|
||
from publish.junit import JUnitTreeOrException, ParsedJUnitFile | ||
|
||
with (pathlib.Path(__file__).parent / 'xslt' / 'trx-to-junit.xslt').open('r', encoding='utf-8') as r: | ||
transform_trx_to_junit = etree.XSLT(etree.parse(r)) | ||
|
||
|
||
def parse_trx_files(files: Iterable[str], | ||
progress: Callable[[ParsedJUnitFile], ParsedJUnitFile] = lambda x: x) -> Iterable[ParsedJUnitFile]: | ||
def parse(path: str) -> JUnitTreeOrException: | ||
"""Parses a trx file and returns either a JUnitTree or an Exception.""" | ||
if not os.path.exists(path): | ||
return FileNotFoundError(f'File does not exist.') | ||
if os.stat(path).st_size == 0: | ||
return Exception(f'File is empty.') | ||
|
||
try: | ||
trx = etree.parse(path) | ||
return transform_trx_to_junit(trx) | ||
except BaseException as e: | ||
return e | ||
|
||
return [progress((result_file, parse(result_file))) for result_file in files] |
Oops, something went wrong.