From 75ea945a2d4e58a16dbfb32489d2b3dd53a176b8 Mon Sep 17 00:00:00 2001 From: Rinary <72972221+Rinary1@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:38:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20(#491)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * init * fix capitulation * fix path * fix tags * upd * пустой коммит * fix !type: --- .github/workflows/validate-locale.yml | 1 + Tools/_sunrise/Schemas/validate_yml.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-locale.yml b/.github/workflows/validate-locale.yml index ca0a71a9e9..d33f224bc3 100644 --- a/.github/workflows/validate-locale.yml +++ b/.github/workflows/validate-locale.yml @@ -23,3 +23,4 @@ jobs: - name: Validate Locales run: | python3 Tools/_sunrise/Schemas/validate_yml.py Resources/ + diff --git a/Tools/_sunrise/Schemas/validate_yml.py b/Tools/_sunrise/Schemas/validate_yml.py index 467340ec78..dfe0353541 100644 --- a/Tools/_sunrise/Schemas/validate_yml.py +++ b/Tools/_sunrise/Schemas/validate_yml.py @@ -31,16 +31,29 @@ def check_dir(dir: str): def check_yml(yml_path: str): try: with open(yml_path, "r", encoding="utf-8") as file: - data = yaml.load(file, Loader=yaml.Loader) + content = file.read() + # Удаляем строки с тегами !type: + filtered_content = remove_type_tags(content) + + # Загружаем оставшийся текст в формате YAML + data = yaml.safe_load(filtered_content) # Проверка нужных полей на русские символы for key in ['name', 'description', 'suffix']: if key in data and has_russian_chars(data[key]): add_error(yml_path, f"Поле '{key}' содержит русские символы.") + except yaml.YAMLError as e: + add_error(yml_path, f"Ошибка чтения файла YAML: {e}") except Exception as e: add_error(yml_path, f"Ошибка чтения файла: {e}") +def remove_type_tags(content: str) -> str: + """Удаляет строки с тегами !type:.""" + lines = content.splitlines() + filtered_lines = [line for line in lines if '!type:' not in line] + return '\n'.join(filtered_lines) + def has_russian_chars(text: str) -> bool: """Проверяет, содержит ли текст русские символы.""" return bool(re.search(r'[а-яА-Я]', text))