1
0
mirror of https://github.com/240596448/onec_codetemplate_parser.git synced 2025-11-23 21:34:39 +02:00

комментарии, исправления

This commit is contained in:
Vladimir Nadulich
2025-10-30 11:38:06 +03:00
parent e9aa3f257f
commit d2487b46db
4 changed files with 12 additions and 9 deletions

View File

@@ -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

View File

@@ -1,13 +1,14 @@
"""Консольное приложение для вызова API библиотеки """
import typer
from .api import parse_to_src, render_from_src
app = typer.Typer(help="Парсер шаблонов ")
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):

View File

@@ -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()

View File

@@ -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):