|
|
@ -2,7 +2,7 @@
|
|
|
|
#
|
|
|
|
#
|
|
|
|
from collections import OrderedDict
|
|
|
|
from collections import OrderedDict
|
|
|
|
from jinja2 import Environment, PackageLoader
|
|
|
|
from jinja2 import Environment, PackageLoader
|
|
|
|
from typing import Callable, List, Tuple
|
|
|
|
from typing import Callable, List, Tuple, Union
|
|
|
|
from pprint import pprint
|
|
|
|
from pprint import pprint
|
|
|
|
from copy import copy
|
|
|
|
from copy import copy
|
|
|
|
import re
|
|
|
|
import re
|
|
|
@ -19,30 +19,29 @@ class FormatError(Exception):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Format:
|
|
|
|
class Format:
|
|
|
|
FORMAT = 'none'
|
|
|
|
FORMAT: str = 'none'
|
|
|
|
CALCULATE_VERSION = None
|
|
|
|
CALCULATE_VERSION: Union[str, None] = None
|
|
|
|
|
|
|
|
SHEBANG_PATTERN: str = r"^(?P<shebang>#!\s*[\w\d\/]+\n)"
|
|
|
|
SHEBANG_PATTERN = r"^(?P<shebang>#!\s*[\w\d\/]+\n)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, processing_methods: List[Callable]):
|
|
|
|
def __init__(self, processing_methods: List[Callable]):
|
|
|
|
self._processing_methods = processing_methods
|
|
|
|
self._processing_methods: List[Callable] = processing_methods
|
|
|
|
self._document_dictionary = OrderedDict()
|
|
|
|
self._document_dictionary: OrderedDict = OrderedDict()
|
|
|
|
self._item_to_add = OrderedDict()
|
|
|
|
self._item_to_add: OrderedDict = OrderedDict()
|
|
|
|
|
|
|
|
|
|
|
|
self.TEMPLATES_DIRECTORY = 'templates'
|
|
|
|
self.TEMPLATES_DIRECTORY: str = 'templates'
|
|
|
|
|
|
|
|
|
|
|
|
self._fatal_error_flag = False
|
|
|
|
self._fatal_error_flag: bool = False
|
|
|
|
self._ready_to_update = False
|
|
|
|
self._ready_to_update: bool = False
|
|
|
|
self._match = False
|
|
|
|
self._match: bool = False
|
|
|
|
|
|
|
|
|
|
|
|
self._need_finish = False
|
|
|
|
self._need_finish: bool = False
|
|
|
|
self._comments_processing = False
|
|
|
|
self._comments_processing: bool = False
|
|
|
|
|
|
|
|
|
|
|
|
self._join_before = False
|
|
|
|
self._join_before: bool = False
|
|
|
|
self._join_before_in_areas = False
|
|
|
|
self._join_before_in_areas: bool = False
|
|
|
|
|
|
|
|
|
|
|
|
# для отладки.
|
|
|
|
# для отладки.
|
|
|
|
self._line_timer = 0
|
|
|
|
self._line_timer: int = 0
|
|
|
|
|
|
|
|
|
|
|
|
def _lines_to_dictionary(self, document_lines: List[str]) -> None:
|
|
|
|
def _lines_to_dictionary(self, document_lines: List[str]) -> None:
|
|
|
|
'''Основной метод для парсинга документа. Принимает список строк,
|
|
|
|
'''Основной метод для парсинга документа. Принимает список строк,
|
|
|
|