From d53a548ebc7d6f7df186e43f3864c2e51377de85 Mon Sep 17 00:00:00 2001 From: David Benepe Date: Mon, 7 Feb 2022 12:48:48 -0500 Subject: [PATCH] Fixed up minor issues with fix_regional_names.py script --- tools/python/fix_regional_names.py | 25 ++++++++++--------------- tools/python/regional_names.json | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/tools/python/fix_regional_names.py b/tools/python/fix_regional_names.py index 02bd55c1..59ac9fec 100755 --- a/tools/python/fix_regional_names.py +++ b/tools/python/fix_regional_names.py @@ -6,6 +6,9 @@ import os from file_util import FileUtil +# Make sure this gets run in the project's base directory. +FileUtil.set_working_dir_to_project_base() + # This script converts all symbol names between US and UK english. REGEX_MAP_SYMBOL = r"[ ]{16}0x[0-9A-Fa-f]{16}[ ]{16}([a-zA-Z_][a-zA-Z0-9_]*)\n" @@ -17,7 +20,7 @@ TERMINAL_COLOR_RESET = "\033[0m" REGIONAL_NAMES_JSON_PATH = 'tools/python/regional_names.json' -# Note: All names MUST be lowercase +# Note: All words MUST be lowercase diffMap = json.loads(FileUtil.get_text_from_file(REGIONAL_NAMES_JSON_PATH))['diffMap'] convertRegion = 'to_uk' @@ -26,11 +29,7 @@ def precheckForErrors(version): if not FileUtil.does_file_exist(versionBuildPath): print('Error: "' + versionBuildPath + '" could not be found. You should have an OK build before running this script!') return None - symMapPath = versionBuildPath + '/dkr.map' - if not FileUtil.does_file_exist(symMapPath): - print('Error: "' + symMapPath + '" could not be found. Make sure this script is running from the root directory of the repo.') - return None - return symMapPath + return versionBuildPath + '/dkr.map' def filterSymMapText(symMapText): newSymMapText = '' @@ -44,16 +43,13 @@ def filterSymMapText(symMapText): for i in range(0, len(lines)): line = lines[i] - if state == 0: - if line.startswith('.main'): - state = 1 + if state == 0 and line.startswith('.main'): + state = 1 elif state == 1: - if line.startswith(' build/'): - if '/lib/' not in line: + if line.startswith(' build/') and '/lib/' not in line: state = 2 elif state == 2: - if line.startswith(' build/'): - if '/lib/' in line: + if line.startswith(' build/') and '/lib/' in line: state = 1 continue if line.startswith('/DISCARD/'): @@ -124,7 +120,6 @@ def filterOutSymbols(symbols): # Symbol can't be processed, so just skip it. continue - #for i in range(0, len(diffMap)): for part in symbolParts: lowerPart = part.lower() if lowerPart in diffMap[convertRegion]: @@ -143,7 +138,6 @@ def validateReplaces(symbolReplaces): print(TERMINAL_COLOR_YELLOW + "Enter 'y' or nothing to accept change, 'n' to discard change, 'x' to abort" + TERMINAL_COLOR_RESET) for symbol in symbolReplaces: - #entry = symbolReplaces[symbol][0] oldSymbol = symbol for entry in symbolReplaces[symbol]: oldWord = entry["subsymbol"] @@ -201,3 +195,4 @@ def main(): if __name__ == "__main__": main() + diff --git a/tools/python/regional_names.json b/tools/python/regional_names.json index 9a38cf26..23bd5492 100644 --- a/tools/python/regional_names.json +++ b/tools/python/regional_names.json @@ -1,5 +1,5 @@ { - "note": "All names must be lower case!", + "note": "All words must be lower case!", "diffMap": { "to_uk": { "accessorize": "accessorise",