pep8 cleanup

This commit is contained in:
Campbell Barton
2011-02-04 09:27:25 +00:00
parent f0eb3b56de
commit 736a7b7a22
21 changed files with 328 additions and 234 deletions

View File

@@ -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)):