| Conditions | 2 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 22 |
| Ratio | 100 % |
| Tests | 12 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | 1 | import os |
|
| 28 | 1 | def process(self, infile: str, outfile: str) -> int: |
|
| 29 | """ |
||
| 30 | Processes a SDoc1 document. |
||
| 31 | |||
| 32 | :param str infile: The input filename with the SDoc1 document. |
||
| 33 | :param str outfile: The output filename with the SDoc2 document. |
||
| 34 | """ |
||
| 35 | 1 | in_stream = antlr4.FileStream(infile) |
|
| 36 | |||
| 37 | 1 | self._io.write_line('Writing <fso>{0!s}</fso>'.format(outfile)) |
|
| 38 | 1 | with open(outfile, 'wt') as out_stream: |
|
| 39 | 1 | lexer = sdoc1Lexer(in_stream) |
|
| 40 | 1 | tokens = antlr4.CommonTokenStream(lexer) |
|
| 41 | 1 | parser = sdoc1Parser(tokens) |
|
| 42 | 1 | tree = parser.sdoc() |
|
| 43 | |||
| 44 | 1 | visitor = SDoc1Visitor(self._io, root_dir=os.path.dirname(os.path.realpath(infile))) |
|
| 45 | |||
| 46 | 1 | visitor.output = out_stream |
|
| 47 | 1 | visitor.visit(tree) |
|
| 48 | |||
| 49 | 1 | return visitor.errors |
|
| 50 | |||
| 52 |