Style fixes in run_checks

This commit is contained in:
Florian Bruhin 2014-02-10 11:07:21 +01:00
parent e49a0aa0ed
commit 921464ef5e

View File

@ -26,7 +26,12 @@ import os
import os.path
from collections import OrderedDict
import pep257
try:
import pep257
except ImportError:
do_check_257 = False
else:
do_check_257 = True
from pkg_resources import load_entry_point, DistributionNotFound
status = OrderedDict()
@ -61,19 +66,20 @@ options = {
'locally-disabled',
],
'flake8': [
'E241', # Multiple spaces after ,
'E241', # Multiple spaces after ,
],
'pep257': [
'D102', # Docstring missing, will be handled by others
'D102', # Docstring missing, will be handled by others
],
},
'exclude': [ 'appdirs.py' ],
'exclude': ['appdirs.py'],
'other': {
'pylint': ['--output-format=colorized', '--reports=no'],
'flake8': ['--max-complexity=10'],
},
}
def run(name, args=None):
""" Run a checker via distutils with optional args.
@ -101,6 +107,7 @@ def run(name, args=None):
status[name] = None
print()
def check_pep257(args=None):
sys.argv = ['pep257', options['target']]
if args is not None:
@ -110,9 +117,10 @@ def check_pep257(args=None):
status['pep257'] = pep257.main(*pep257.parse_options())
except Exception as e:
print('{}: {}'.format(e.__class__.__name__, e))
status[name] = None
status['pep257'] = None
print()
def check_line():
"""Checks a filetree for CRLFs, conflict markers and weird whitespace"""
print("====== line ======")
@ -128,6 +136,7 @@ def check_line():
status['line'] = None
print()
def _check_line(fn):
with open(fn, 'rb') as f:
for line in f:
@ -146,6 +155,7 @@ def _check_line(fn):
return False
return True
def _get_args(checker):
args = []
if checker == 'pylint':
@ -166,13 +176,15 @@ def _get_args(checker):
args = []
try:
args += ['--ignore=' + ','.join(options['disable']['pep257'])]
args += ['--match=(?!{}).*\.py'.format('|'.join(options['exclude']))]
args += ['--match=(?!{}).*\.py'.format('|'.join(
options['exclude']))]
args += options['other']['pep257']
except KeyError:
pass
return args
check_pep257(_get_args('pep257'))
if do_check_257:
check_pep257(_get_args('pep257'))
for checker in ['pylint', 'flake8']:
# FIXME what the hell is the flake8 exit status?
run(checker, _get_args(checker))