You've already forked onec_codetemplate_parser
mirror of
https://github.com/240596448/onec_codetemplate_parser.git
synced 2025-11-23 21:34:39 +02:00
ref
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
"""Программный интерфейс"""
|
||||
|
||||
from .core import parser as parser
|
||||
from .core import Root
|
||||
from pathlib import Path
|
||||
|
||||
from .core import Root, parser
|
||||
|
||||
def parse_to_src(path: str, src: str):
|
||||
"""Парсит шаблон 1С-файла и сохраняет структуру файлов в папку"""
|
||||
@@ -14,4 +12,4 @@ def render_from_src(src: str, path: str):
|
||||
"""Генерирует код шаблона из исходников"""
|
||||
root = Root.from_files(src)
|
||||
text = root.compile()
|
||||
Path(path).write_text(text, encoding='utf-8-sig')
|
||||
Path(path).write_text(text, encoding='utf-8-sig')
|
||||
|
||||
7
setup.py
7
setup.py
@@ -1,7 +0,0 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="onec_codetemplate_parser",
|
||||
version="0.1.0",
|
||||
packages=find_packages(),
|
||||
)
|
||||
@@ -1,14 +1,16 @@
|
||||
import pytest
|
||||
"""fixtures for tests"""
|
||||
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
TEST_FILE = 'Documents/1C/1c-text-tempates/Надулич.st'
|
||||
TEST_FILE = 'Documents/1C/1c-code-templates/Надулич.st'
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def test_file_path():
|
||||
@pytest.fixture(scope="class", name="test_file_path")
|
||||
def test_data_path():
|
||||
return Path.home() / TEST_FILE
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def test_data(test_file_path):
|
||||
def test_data(test_file_path):
|
||||
file_data = test_file_path.read_text(encoding='utf-8-sig')
|
||||
return file_data
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from onec_codetemplate_parser import core
|
||||
from tests.common import check_files_sequential
|
||||
|
||||
class Test_Read_Skobkofile:
|
||||
class TestReadSkobkofile:
|
||||
|
||||
def test_00_test_file_exist(self, test_file_path):
|
||||
assert test_file_path.exists()
|
||||
@@ -21,7 +21,7 @@ class Test_Read_Skobkofile:
|
||||
assert new_data == test_data
|
||||
|
||||
|
||||
class Test_Write_To_Files:
|
||||
class TestWriteToFiles:
|
||||
|
||||
def test_00_to_file(self, test_data, temp_src):
|
||||
root = core.parser(test_data)
|
||||
@@ -35,11 +35,9 @@ class Test_Write_To_Files:
|
||||
# Проверка: есть ли папки
|
||||
dirs = [p for p in temp_src.iterdir() if p.is_dir()]
|
||||
assert len(dirs) == 1
|
||||
assert (temp_src / "001.0_Надулич") in dirs
|
||||
assert temp_src / "001.0_Надулич" in dirs
|
||||
|
||||
def test_02_sequential_name(self, temp_src):
|
||||
d = temp_src / "001.0_Надулич" / "002.0_Комментарии"
|
||||
subfiles = [p.name for p in d.iterdir()]
|
||||
check_files_sequential(subfiles)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user