diff --git a/calculate/templates/format/json_format.py b/calculate/templates/format/json_format.py index 5724c7c..6858cbd 100644 --- a/calculate/templates/format/json_format.py +++ b/calculate/templates/format/json_format.py @@ -7,38 +7,37 @@ import json class JSONFormat(Format): - FORMAT = 'json' - EXECUTABLE = False + FORMAT: str = 'json' + EXECUTABLE: bool = False - comment_symbol = False + comment_symbol: bool = False def __init__(self, document_text: str, - template_path, - ignore_comments=False, - join_before=False, - add_header=False, - already_changed=False, - parameters=ParametersContainer()): - processing_methods = [] + template_path: str, + ignore_comments: bool = False, + join_before: bool = False, + add_header: bool = False, + already_changed: bool = False, + parameters: ParametersContainer = ParametersContainer()): + processing_methods: list = [] super().__init__(processing_methods) - self._ignore_comments = ignore_comments - self._join_before = join_before - self._comments_processing = False + self._ignore_comments: bool = ignore_comments + self._join_before: bool = join_before + self._comments_processing: bool = False # Пока что не добавляет заголовок, потому что не очень ясно, как это # делать. if document_text == '': - self._document_dictionary = OrderedDict() + self._document_dictionary: OrderedDict = OrderedDict() else: self._text_to_dictionary(document_text) - def _text_to_dictionary(self, json_file_text): + def _text_to_dictionary(self, json_file_text: str) -> None: '''Метод для получения словаря документа, переопределяющий метод базового класса.''' self._document_dictionary = json.loads(json_file_text, - object_pairs_hook=OrderedDict, - encoding="utf8") + object_pairs_hook=OrderedDict) @property def document_text(self): diff --git a/calculate/templates/template_processor.py b/calculate/templates/template_processor.py index 0933358..67b937e 100644 --- a/calculate/templates/template_processor.py +++ b/calculate/templates/template_processor.py @@ -1705,6 +1705,8 @@ class TemplateExecutor: def _chmod_directory(self, target_path: str, chmod_value: int) -> None: '''Метод для смены прав доступа к директории.''' + if isinstance(chmod_value, tuple) and not chmod_value[1]: + chmod_value = chmod_value[0] try: if os.path.exists(target_path): if isinstance(chmod_value, int): diff --git a/calculate/utils/.package.py.swo b/calculate/utils/.package.py.swo deleted file mode 100644 index ff78fcf..0000000 Binary files a/calculate/utils/.package.py.swo and /dev/null differ diff --git a/calculate/utils/package.py b/calculate/utils/package.py index c60d7fd..cc1b0b6 100644 --- a/calculate/utils/package.py +++ b/calculate/utils/package.py @@ -356,7 +356,6 @@ class ContentsParser(metaclass=Singleton): class OldContentsParser(metaclass=Singleton): def __init__(self): - '''Метод для инициализации парсеров.''' sym_keyword = Literal('sym') dir_keyword = Literal('dir') obj_keyword = Literal('obj')