Restructure: remove separate parser

This commit is contained in:
Jonas Zeunert
2024-04-27 15:38:36 +02:00
parent 8e5cf17c0b
commit e03a70cc05
4 changed files with 16 additions and 34 deletions

View File

@@ -1,8 +1,10 @@
class Converter: from kiutils.footprint import Footprint
input = ""
def __init__(self, input: str): class Converter:
self.input = input footprint: Footprint
def __init__(self, footprint: Footprint):
self.footprint = footprint
def convert(self) -> str: def convert(self) -> str:
return "" return ""

View File

@@ -3,23 +3,25 @@
from argparse import ArgumentParser from argparse import ArgumentParser
from pathlib import Path from pathlib import Path
from ergogen_footprint_converter.parser import Parser from .converter import Converter
from ergogen_footprint_converter.converter import Converter
from kiutils.footprint import Footprint
def main (args) -> None: def main (args) -> None:
check_args(args) check_args(args)
in_file: Path = args["in_file"] converted = convert(args["in_file"])
out_dir: Path = args["out"]
parser = Parser(in_file) write_output(converted, args["in_file"], args["out"])
parsed = parser.parse()
def convert(in_file: Path) -> str:
parsed = Footprint.from_file(in_file.absolute().__str__())
converter = Converter(parsed) converter = Converter(parsed)
converted = converter.convert()
write_output(converted, in_file, out_dir) return converter.convert()
def write_output (output: str, in_file: Path, out_dir: Path) -> None: def write_output (output: str, in_file: Path, out_dir: Path) -> None:
filename = in_file.name filename = in_file.name

View File

@@ -1,12 +0,0 @@
from kiutils.footprint import Footprint
from pathlib import Path
class Parser():
footprint: Footprint
def __init__(self, input_file: Path):
self.footprint = Footprint.from_file(input_file.absolute().__str__())
def parse(self) -> str:
return ""

View File

@@ -1,10 +0,0 @@
from ergogen_footprint_converter.parser import Parser
import pytest
from pathlib import Path
def test_parser_filenotexists():
with pytest.raises(Exception, match=r".*Given path is not a file.*"):
Parser(Path("nop"))
def test_parse():
None