Stringtable Validator - Check for tabs and correct spacing (#7332)

* Stringtable Validator - Check for tabs and correct spacing

* Improve error descriptions, Cleanup

* Change encoding to utf-8

Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>
This commit is contained in:
PabstMirror 2019-12-26 19:42:30 -06:00 committed by GitHub
parent 8e24d95b37
commit 53c53bbdbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -869,9 +869,7 @@
<Chinese>已使用固定板</Chinese>
<Czech>Dlaha aplikována</Czech>
</Key>
<!--
Strings above match Blood2 but seem to differ in some languages, determine which is best to use
-->
<!--Strings above match Blood2 but seem to differ in some languages, determine which is best to use-->
<Key ID="STR_ACE_Medical_GUI_Lost_Blood1">
<English>Lost some blood</English>
<German>Hat etwas Blut verloren</German>

View File

@ -115,6 +115,29 @@ def check_stringtable(filepath):
print(" ERROR: Key '{}' is defined {} times.".format(id, count))
errors += 1
# Check whitespace for tabs and correct number of indenting spaces
with open(filepath, "r", encoding = "utf-8") as file:
spacing_depth = 0
for line_number, line in enumerate(file, 1):
if "\t" in line:
print(" ERROR: Found a tab on line {}.".format(line_number))
errors += 1
line_clean = line.lstrip().lower()
if line_clean.startswith("</key") or line_clean.startswith("</package") or line_clean.startswith("</project") or line_clean.startswith("</container"):
spacing_depth -= 4
line_spacing = len(line) - len(line_clean)
if line_spacing != spacing_depth:
print(" ERROR: Incorrect number of indenting spaces on line {}, currently {}, should be {}.".format(line_number, line_spacing, spacing_depth))
errors += 1
if line_clean.startswith("<key") or line_clean.startswith("<package") or line_clean.startswith("<project") or line_clean.startswith("<container"):
spacing_depth += 4
return errors