diff --git a/onec_codetemplate_parser/api.py b/onec_codetemplate_parser/api.py index 44d2bd2..228e750 100644 --- a/onec_codetemplate_parser/api.py +++ b/onec_codetemplate_parser/api.py @@ -1,4 +1,6 @@ -from .core import parse_skobkofile as parser +"""Программный интерфейс""" + +from .core import parser as parser from .core import Root from pathlib import Path diff --git a/onec_codetemplate_parser/cli.py b/onec_codetemplate_parser/cli.py index e6cb294..5a4b659 100644 --- a/onec_codetemplate_parser/cli.py +++ b/onec_codetemplate_parser/cli.py @@ -1,13 +1,14 @@ +"""Консольное приложение для вызова API библиотеки """ + import typer from .api import parse_to_src, render_from_src -app = typer.Typer(help="Парсер шаблонов 1С") +app = typer.Typer(help="Парсер шаблонов кода 1С (*.st)") @app.command() def parse(path: str, src: str): """Разобрать шаблон из 1с-файла *.st в исходники src""" - result = parse_to_src(path, src) - typer.echo(result) + parse_to_src(path, src) @app.command() def render(src: str, path: str): diff --git a/onec_codetemplate_parser/core.py b/onec_codetemplate_parser/core.py index 20fe620..778704f 100644 --- a/onec_codetemplate_parser/core.py +++ b/onec_codetemplate_parser/core.py @@ -188,7 +188,7 @@ class Root(Node): children.append(child) return Root(len(children), children) -def parse_skobkofile(text: str) -> Root: +def parser(text: str) -> Root: pos = 0 def skip_ws(): @@ -291,7 +291,7 @@ if __name__ == "__main__": with open(path, "r", encoding="utf-8-sig", errors="ignore") as f: text = f.read() - root = parse_skobkofile(text) + root = parser(text) print("\n✅ Файл успешно прочитан\n") root.pretty_print() diff --git a/tests/test_01.py b/tests/test_01.py index a2d60da..f3d5873 100644 --- a/tests/test_01.py +++ b/tests/test_01.py @@ -7,12 +7,12 @@ class Test_Read_Skobkofile: assert test_file_path.exists() def test_01_parse_eq_compile(self, test_data): - root = core.parse_skobkofile(test_data) + root = core.parser(test_data) new_data = root.compile() assert new_data == test_data def test_02_save_and_read(self, test_data, tmp_path): - root = core.parse_skobkofile(test_data) + root = core.parser(test_data) new_data = root.compile() tmp_file = tmp_path / 'tmp.st' @@ -24,7 +24,7 @@ class Test_Read_Skobkofile: class Test_Write_To_Files: def test_00_to_file(self, test_data, temp_src): - root = core.parse_skobkofile(test_data) + root = core.parser(test_data) root.to_files(temp_src) def test_01_to_files(self, temp_src):