Download:
child 53:ed7f35f52927
parent 51:0552f5ca41a3
52:e1ca1959db76
Anton Shestakov <av6@dwimlabs.net>, Thu, 23 Jun 2016 14:38:55 +0800
checker: make run_ignore_1() a bit more flexible by adding codes argument

1 файлов изменено, 7 вставок(+), 7 удалений(-) [+]
checker.py file | annotate | diff | comparison | revisions
--- a/checker.py Mon Jun 20 00:11:57 2016 +0800
+++ b/checker.py Thu Jun 23 14:38:55 2016 +0800
@@ -11,16 +11,16 @@
import yaml
-def run_ignore_1(fn, args):
+def run_ignore_codes(fn, args, codes):
try:
return fn(args)
except CalledProcessError as e:
- if e.returncode != 1:
+ if e.returncode not in codes:
raise
return e.output
-def run(args, silent=False, get_output=False, ignore_1=False):
+def run(args, silent=False, get_output=False, ignore_codes=None):
if get_output:
fn = check_output
else:
@@ -28,8 +28,8 @@
try:
if not silent:
print('$ ' + ' '.join(args))
- if ignore_1:
- result = run_ignore_1(fn, args)
+ if ignore_codes:
+ result = run_ignore_codes(fn, args, ignore_codes)
else:
result = fn(args)
if get_output:
@@ -94,7 +94,7 @@
continue
cmd = ['hg', 'files', 'set:' + ' or '.join(linter['files'])]
- files = run(cmd, silent=True, get_output=True, ignore_1=True)
+ files = run(cmd, silent=True, get_output=True, ignore_codes=(1,))
if files is False:
ok = False
break
@@ -102,7 +102,7 @@
for f in files.splitlines():
if 'pip' in linter:
cmd = [os.path.join(venv, 'bin', linter['cmd'])]
- if not run(cmd + linter.get('flags', []) + [f], ignore_1=True):
+ if not run(cmd + linter.get('flags', []) + [f], ignore_codes=(1,)):
ok = False
break