forked from wbond/asn1crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
61 lines (43 loc) · 1.22 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import sys
if sys.version_info < (3,):
byte_cls = str
else:
byte_cls = bytes
def show_usage():
print('Usage: run.py (lint | tests [regex] | coverage | deps | ci | release)', file=sys.stderr)
sys.exit(1)
def get_arg(num):
if len(sys.argv) < num + 1:
return None, num
arg = sys.argv[num]
if isinstance(arg, byte_cls):
arg = arg.decode('utf-8')
return arg, num + 1
if len(sys.argv) < 2 or len(sys.argv) > 3:
show_usage()
task, next_arg = get_arg(1)
if task not in set(['lint', 'tests', 'coverage', 'deps', 'ci', 'release']):
show_usage()
if task != 'tests' and len(sys.argv) == 3:
show_usage()
params = []
if task == 'lint':
from dev.lint import run
elif task == 'tests':
from dev.tests import run
matcher, next_arg = get_arg(next_arg)
if matcher:
params.append(matcher)
elif task == 'coverage':
from dev.coverage import run
elif task == 'deps':
from dev.deps import run
elif task == 'ci':
from dev.ci import run
elif task == 'release':
from dev.release import run
result = run(*params)
sys.exit(int(not result))