--- a/checker.py Thu Jun 23 15:06:21 2016 +0800
+++ b/checker.py Thu Jun 23 15:21:20 2016 +0800
+rel = lambda *x: os.path.abspath(os.path.join(os.path.dirname(__file__), *x))
def run_ignore_codes(fn, args, codes):
return datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S+00:00')
+def read_linter_config(name, path=rel('linters')):
+ fd = open(os.path.join(path, '{}.yml'.format(name)))
+ print("# C&O couldn't load linter config: {}".format(e))
+ return yaml.safe_load(fd)
+ print("# C&O couldn't parse linter config: {}".format(e))
print('# C&O task: setup')
- run(['virtualenv', venv])
- pip = os.path.join(venv, 'bin', 'pip')
for linter in config['linters']:
- if not run([pip, 'install'] + linter['pip']):
+ if 'name' not in linter:
+ if name in linter_config:
+ lc = read_linter_config(name)
+ if lc is None or 'exec' not in lc:
+ linter_config[name] = lc
+ for item in lc.get('setup', []):
+ if 'version' in lc and not run(lc['exec'] + lc['version']):
print('# C&O task: checks')
for linter in config['linters']:
- if 'include' not in linter:
+ if 'name' not in linter or 'include' not in linter:
+ if linter['name'] not in linter_config:
+ lc = linter_config[linter['name']]
for f in files.splitlines():
- cmd = [os.path.join(venv, 'bin', linter['cmd'])]
- if not run(cmd + linter.get('flags', []) + [f], ignore_codes=(1,)):
+ flags = lc.get('flags', []) + linter.get('flags', [])
+ pf = lc.get('post_flags', []) + linter.get('post_flags', [])
+ if not run(cmd + flags + [f] + pf, ignore_codes=(1,)):