Commit 895a5145 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Added line endings check to style test

parent 01d62939
......@@ -150,6 +150,26 @@ def checkStyle():
ret = proc.wait()
# Check for DOS newlines
print('check line endings in all files...')
count = 0
allowedEndings = set([None, '\n'])
for path, dirs, files in os.walk('.'):
for f in files:
if os.path.splitext(f)[1] not in ('.py', '.rst'):
filename = os.path.join(path, f)
fh = open(filename, 'U')
x = fh.readlines()
endings = set(fh.newlines if isinstance(fh.newlines, tuple) else (fh.newlines,))
endings -= allowedEndings
if len(endings) > 0:
print("\033[0;31m" + "File has invalid line endings: %s" % filename + "\033[0m")
ret = ret | 2
count += 1
print('checked line endings in %d files' % count)
# Next check new code with optional error codes
print('flake8: check new code against recommended error set...')
diff = subprocess.check_output(['git', 'diff'])
......@@ -163,9 +183,9 @@ def checkStyle():
ret |= printFlakeOutput(output)
if ret == 0:
print('flake8 test passed.')
print('style test passed.')
print('flake8 test failed: %d' % ret)
print('style test failed: %d' % ret)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment