Skip to content

Commit

Permalink
Add exception handling and prevent reformatting of ts files and disab…
Browse files Browse the repository at this point in the history
…le multi threading
  • Loading branch information
daschuer committed Jun 30, 2024
1 parent 66c0b17 commit 7afcc71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)$
Expand Down Expand Up @@ -178,6 +178,7 @@ repos:
stages:
- commit
- manual
require_serial: true
language: python
additional_dependencies:
- lxml==4.9.3
Expand Down
21 changes: 18 additions & 3 deletions tools/ts_source_copy_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 7afcc71

Please sign in to comment.