diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 41795086df98..4472e465dffe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: - id: check-yaml exclude: ^\.clang-format$ - id: end-of-file-fixer - exclude: ^.*UTF-8-BOM.txt$ + exclude: ^.*(UTF-8-BOM\.txt|\.ts)$ - id: mixed-line-ending - id: trailing-whitespace exclude: \.(c|cc|cxx|cpp|ts|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|mm|proto|vert)$ @@ -178,6 +178,7 @@ repos: stages: - commit - manual + require_serial: true language: python additional_dependencies: - lxml==4.9.3 diff --git a/tools/ts_source_copy_check.py b/tools/ts_source_copy_check.py index bec83faefcc4..04f703c0ae47 100755 --- a/tools/ts_source_copy_check.py +++ b/tools/ts_source_copy_check.py @@ -21,7 +21,12 @@ def is_untranstaled_allowed(source_text, language): if os.path.exists(ALLOW_LIST_PATH): parser = etree.XMLParser(recover=True) - tree = etree.parse(ALLOW_LIST_PATH, parser) + try: + tree = etree.parse(ALLOW_LIST_PATH, parser) + except Exception as e: + print("XML parsing failed:") + print(e) + return root = tree.getroot() else: return False @@ -44,12 +49,22 @@ def is_untranstaled_allowed(source_text, language): def add_to_allow_list(source_text, language): if os.path.exists(PROPOSED_ALLOW_LIST_PATH): parser = etree.XMLParser(recover=True) - tree = etree.parse(PROPOSED_ALLOW_LIST_PATH, parser) + try: + tree = etree.parse(PROPOSED_ALLOW_LIST_PATH, parser) + except Exception as e: + print("XML parsing failed:") + print(e) + return root = tree.getroot() else: if os.path.exists(ALLOW_LIST_PATH): parser = etree.XMLParser(recover=True) - tree = etree.parse(ALLOW_LIST_PATH, parser) + try: + tree = etree.parse(ALLOW_LIST_PATH, parser) + except Exception as e: + print("XML parsing failed:") + print(e) + return root = tree.getroot() else: root = etree.Element("allow_list")