mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
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:
parent
8e24d95b37
commit
53c53bbdbc
@ -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>
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user