check_tfs.py: ignore utf-8 encoding errors

This commit is contained in:
Martin Kaiser 2023-12-07 11:55:21 +00:00 committed by Martin Mathieson
parent 2971ce995d
commit 70497ac5f8
1 changed files with 5 additions and 5 deletions

View File

@ -39,7 +39,7 @@ def isGeneratedFile(filename):
return False
# Open file
f_read = open(os.path.join(filename), 'r')
f_read = open(os.path.join(filename), 'r', encoding="utf8", errors="ignore")
lines_tested = 0
for line in f_read:
# The comment to say that its generated is near the top, so give up once
@ -289,7 +289,7 @@ def removeComments(code_string):
def findTFS(filename):
tfs_found = {}
with open(filename, 'r', encoding="utf8") as f:
with open(filename, 'r', encoding="utf8", errors="ignore") as f:
contents = f.read()
# Example: const true_false_string tfs_yes_no = { "Yes", "No" };
@ -317,7 +317,7 @@ def findValueStrings(filename):
# { 0, NULL }
#};
with open(filename, 'r', encoding="utf8") as f:
with open(filename, 'r', encoding="utf8", errors="ignore") as f:
contents = f.read()
# Remove comments so as not to trip up RE.
@ -335,7 +335,7 @@ def findValueStrings(filename):
def find_items(filename, macros, check_mask=False, mask_exact_width=False, check_label=False, check_consecutive=False):
is_generated = isGeneratedFile(filename)
items = {}
with open(filename, 'r', encoding="utf8") as f:
with open(filename, 'r', encoding="utf8", errors="ignore") as f:
contents = f.read()
# Remove comments so as not to trip up RE.
contents = removeComments(contents)
@ -354,7 +354,7 @@ def find_items(filename, macros, check_mask=False, mask_exact_width=False, check
def find_macros(filename):
macros = {}
with open(filename, 'r', encoding="utf8") as f:
with open(filename, 'r', encoding="utf8", errors="ignore") as f:
contents = f.read()
# Remove comments so as not to trip up RE.
contents = removeComments(contents)