diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-02-04 12:27:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-02-04 12:27:25 +0300 |
commit | 736a7b7a2280a843686b7699fc9d96915801a459 (patch) | |
tree | c3e584113a39628225d9b2cac16d414258a5921a /build_files/cmake/cmake_consistency_check.py | |
parent | f0eb3b56de1456b973098640b7eda47c7e1d58a0 (diff) |
pep8 cleanup
Diffstat (limited to 'build_files/cmake/cmake_consistency_check.py')
-rw-r--r-- | build_files/cmake/cmake_consistency_check.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py index 0998d221b00..87bbc929a93 100644 --- a/build_files/cmake/cmake_consistency_check.py +++ b/build_files/cmake/cmake_consistency_check.py @@ -21,6 +21,8 @@ # # ***** END GPL LICENSE BLOCK ***** +# <pep8 compliant> + IGNORE = \ "/test/",\ "/decimate_glut_test/",\ @@ -45,6 +47,8 @@ global_c = set() import os from os.path import splitext + + def source_list(path, filename_check=None): for dirpath, dirnames, filenames in os.walk(path): @@ -56,31 +60,37 @@ def source_list(path, filename_check=None): if filename_check is None or filename_check(filename): yield os.path.join(dirpath, filename) + # extension checking def is_c_header(filename): ext = splitext(filename)[1] return (ext in (".h", ".hpp", ".hxx")) + def is_cmake(filename): ext = splitext(filename)[1] return (ext == ".cmake") or (filename == "CMakeLists.txt") + def is_c_header(filename): ext = splitext(filename)[1] return (ext in (".h", ".hpp", ".hxx")) + def is_c(filename): ext = splitext(filename)[1] return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) + def is_c_any(filename): return is_c(filename) or is_c_header(filename) + def cmake_get_src(f): - + sources_h = [] sources_c = [] - + filen = open(f, "r", encoding="utf8") it = iter(filen) found = False @@ -101,7 +111,7 @@ def cmake_get_src(f): raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i)) found = True break - + if "list(APPEND SRC" in l: if l.endswith(")"): raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i)) @@ -118,11 +128,11 @@ def cmake_get_src(f): except StopIteration: it = None break - + l = l.strip() if not l.startswith("#"): - + if ")" in l: if l.strip() != ")": raise Exception("strict formatting not kept '*)' %s:%d" % (f, i)) @@ -130,7 +140,6 @@ def cmake_get_src(f): # replace dirs l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base) - if not l: pass @@ -140,7 +149,7 @@ def cmake_get_src(f): raise Exception("Multi-line define '%s' %s:%d" % (l, f, i)) else: new_file = normpath(join(cmake_base, l)) - + if is_c_header(new_file): sources_h.append(new_file) elif is_c(new_file): @@ -168,19 +177,20 @@ def cmake_get_src(f): if ff not in sources_c: print(" missing: " + ff) ''' - + filen.close() for cmake in source_list(base, is_cmake): cmake_get_src(cmake) + def is_ignore(f): for ig in IGNORE: if ig in f: return True return False - + # First do stupid check, do these files exist? for f in (global_h | global_c): if f.endswith("dna.c"): @@ -189,7 +199,7 @@ for f in (global_h | global_c): if not os.path.exists(f): raise Exception("CMake referenced file missing: " + f) - + # now check on files not accounted for. print("\nC/C++ Files CMake doesnt know about...") for cf in sorted(source_list(base, is_c)): |