Restructure: remove separate parser
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
class Converter:
|
||||
input = ""
|
||||
from kiutils.footprint import Footprint
|
||||
|
||||
def __init__(self, input: str):
|
||||
self.input = input
|
||||
class Converter:
|
||||
footprint: Footprint
|
||||
|
||||
def __init__(self, footprint: Footprint):
|
||||
self.footprint = footprint
|
||||
|
||||
def convert(self) -> str:
|
||||
return ""
|
||||
|
||||
@@ -3,23 +3,25 @@
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
from ergogen_footprint_converter.parser import Parser
|
||||
from ergogen_footprint_converter.converter import Converter
|
||||
from .converter import Converter
|
||||
|
||||
from kiutils.footprint import Footprint
|
||||
|
||||
|
||||
def main (args) -> None:
|
||||
check_args(args)
|
||||
|
||||
in_file: Path = args["in_file"]
|
||||
out_dir: Path = args["out"]
|
||||
converted = convert(args["in_file"])
|
||||
|
||||
parser = Parser(in_file)
|
||||
parsed = parser.parse()
|
||||
write_output(converted, args["in_file"], args["out"])
|
||||
|
||||
def convert(in_file: Path) -> str:
|
||||
parsed = Footprint.from_file(in_file.absolute().__str__())
|
||||
|
||||
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:
|
||||
filename = in_file.name
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user