Cleanup: spelling & cleanup for cmake_consistency_check

Much more could be done here, some obvious corrections.
This commit is contained in:
Campbell Barton 2021-01-20 15:58:07 +11:00
parent d3fe320b83
commit be970c03c2

@ -20,6 +20,8 @@
# <pep8 compliant> # <pep8 compliant>
# Note: this code should be cleaned up / refactored.
import sys import sys
if sys.version_info.major < 3: if sys.version_info.major < 3:
print("\nPython3.x needed, found %s.\nAborting!\n" % print("\nPython3.x needed, found %s.\nAborting!\n" %
@ -37,7 +39,12 @@ from cmake_consistency_check_config import (
import os import os
from os.path import join, dirname, normpath, splitext from os.path import (
dirname,
join,
normpath,
splitext,
)
global_h = set() global_h = set()
global_c = set() global_c = set()
@ -45,8 +52,8 @@ global_refs = {}
# Flatten `IGNORE_SOURCE_MISSING` to avoid nested looping. # Flatten `IGNORE_SOURCE_MISSING` to avoid nested looping.
IGNORE_SOURCE_MISSING = [ IGNORE_SOURCE_MISSING = [
(k, ig) for k, ig_list in IGNORE_SOURCE_MISSING (k, ignore_path) for k, ig_list in IGNORE_SOURCE_MISSING
for ig in ig_list for ignore_path in ig_list
] ]
# Ignore cmake file, path pairs. # Ignore cmake file, path pairs.
@ -263,16 +270,16 @@ def cmake_get_src(f):
def is_ignore_source(f, ignore_used): def is_ignore_source(f, ignore_used):
for index, ig in enumerate(IGNORE_SOURCE): for index, ignore_path in enumerate(IGNORE_SOURCE):
if ig in f: if ignore_path in f:
ignore_used[index] = True ignore_used[index] = True
return True return True
return False return False
def is_ignore_cmake(f, ignore_used): def is_ignore_cmake(f, ignore_used):
for index, ig in enumerate(IGNORE_CMAKE): for index, ignore_path in enumerate(IGNORE_CMAKE):
if ig in f: if ignore_path in f:
ignore_used[index] = True ignore_used[index] = True
return True return True
return False return False
@ -303,7 +310,7 @@ def main():
for cf, i in refs: for cf, i in refs:
errs.append((cf, i)) errs.append((cf, i))
else: else:
raise Exception("CMake referenecs missing, internal error, aborting!") raise Exception("CMake references missing, internal error, aborting!")
is_err = True is_err = True
errs.sort() errs.sort()
@ -314,7 +321,7 @@ def main():
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf)) # print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
if is_err: if is_err:
raise Exception("CMake referenecs missing files, aborting!") raise Exception("CMake references missing files, aborting!")
del is_err del is_err
del errs del errs
@ -325,7 +332,7 @@ def main():
if cf not in global_c: if cf not in global_c:
print("missing_c: ", cf) print("missing_c: ", cf)
# check if automake builds a corrasponding .o file. # Check if automake builds a corresponding .o file.
''' '''
if cf in global_c: if cf in global_c:
out1 = os.path.splitext(cf)[0] + ".o" out1 = os.path.splitext(cf)[0] + ".o"
@ -361,21 +368,21 @@ def main():
# Check ignores aren't stale # Check ignores aren't stale
print("\nCheck for unused 'IGNORE_SOURCE' paths...") print("\nCheck for unused 'IGNORE_SOURCE' paths...")
for index, ig in enumerate(IGNORE_SOURCE): for index, ignore_path in enumerate(IGNORE_SOURCE):
if not ignore_used_source[index]: if not ignore_used_source[index]:
print("unused ignore: %r" % ig) print("unused ignore: %r" % ignore_path)
# Check ignores aren't stale # Check ignores aren't stale
print("\nCheck for unused 'IGNORE_SOURCE_MISSING' paths...") print("\nCheck for unused 'IGNORE_SOURCE_MISSING' paths...")
for k, v in sorted(global_ignore_source_missing.items()): for k, v in sorted(global_ignore_source_missing.items()):
for ig in v: for ignore_path in v:
print("unused ignore: %r -> %r" % (ig, k)) print("unused ignore: %r -> %r" % (ignore_path, k))
# Check ignores aren't stale # Check ignores aren't stale
print("\nCheck for unused 'IGNORE_CMAKE' paths...") print("\nCheck for unused 'IGNORE_CMAKE' paths...")
for index, ig in enumerate(IGNORE_CMAKE): for index, ignore_path in enumerate(IGNORE_CMAKE):
if not ignore_used_cmake[index]: if not ignore_used_cmake[index]:
print("unused ignore: %r" % ig) print("unused ignore: %r" % ignore_path)
if __name__ == "__main__": if __name__ == "__main__":