scripts: use os.path to form paths

This commit is contained in:
Anton Shestakov
2018-07-28 13:45:56 +08:00
parent 9f255104e1
commit 95a04308d8
3 changed files with 7 additions and 7 deletions

View File

@@ -25,13 +25,13 @@ if len(sys.argv) > 2:
top = os.getcwd()
if len(sys.argv) == 2:
top += '/' + sys.argv[1]
top = os.path.join(top, sys.argv[1])
offending_files = []
for root, dirs, files in os.walk(top):
for f in files:
if f.endswith('.lua'):
path = root + '/' + f
path = os.path.join(root, f)
if is_BOM_encoded_file(path):
offending_files.append(f)

View File

@@ -11,13 +11,13 @@ import sys
regex = r"^class \"(.+)\".*\n\n(?!---@type \1\nlocal \1 = _G\[\"\1\"])"
print_root_regex = re.compile("Lua.*")
script_dir = os.getcwd() + "/../CorsixTH/Lua"
ignored = os.listdir(script_dir + "/languages")
script_dir = os.path.join(os.path.dirname(__file__), "..", "CorsixTH", "Lua")
ignored = os.listdir(os.path.join(script_dir, "languages"))
problem_found = False
for root, _, files in os.walk(script_dir):
for script in files:
if script.endswith(".lua") and script not in ignored:
script_string = open(root + "/" + script, 'r').read()
script_string = open(os.path.join(root, script), 'r').read()
for found_class in re.findall(regex, script_string, re.MULTILINE):
if not problem_found:
print("******* CHECK CLASS DECLARATIONS *******")

View File

@@ -32,12 +32,12 @@ if len(sys.argv) > 2:
top = os.getcwd()
if len(sys.argv) == 2:
top += '/' + sys.argv[1]
top = os.path.join(top, sys.argv[1])
for root, dirs, files in os.walk(top):
for f in files:
if f.endswith(('.py', '.lua', '.h', '.cpp', '.cc', '.c')):
path = root + '/' + f
path = os.path.join(root, f)
if has_trailing_whitespaces(path):
sys.exit('Found a file with trailing whitespaces: ' + path)