From d2487b46db6c493e3780c4ba6ff696eb020d4a62 Mon Sep 17 00:00:00 2001 From: Vladimir Nadulich Date: Thu, 30 Oct 2025 11:38:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B8,=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- onec_codetemplate_parser/api.py | 4 +++- onec_codetemplate_parser/cli.py | 7 ++++--- onec_codetemplate_parser/core.py | 4 ++-- tests/test_01.py | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) 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):