-
Notifications
You must be signed in to change notification settings - Fork 9
/
lint
executable file
·83 lines (75 loc) · 3.01 KB
/
lint
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
"""Runs code checkers on current directory
Written by Peter Duerr
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from subprocess import Popen, PIPE
import sys
from datetime import datetime
from pyexperiment.utils.printers import print_blue # pylint: disable=E0611
CHECKERS = [
['pep8', './pyexperiment'],
['pep8', './tests'],
['pep8', './lint'],
['pep8', './examples/minimal_cli'],
['pep8', './examples/minimal_config'],
['pep8', './examples/test_cli'],
['pep8', './examples/example'],
['pep8', './examples/minimal_logging'],
['pep8', './examples/stopwatch'],
['pep8', './examples/numbers'],
['pep8', './examples/replicate'],
['pep8', './examples/memoize'],
['pep8', './examples/benchmarks'],
['pylint', './pyexperiment', '--reports=n', '--disable=I0011'],
['pylint', './tests', '--reports=n', '--disable=I0011',
'--ignore-imports=y'],
['pylint', './lint', '--reports=n', '--disable=I0011'],
['pylint', './examples/minimal_cli', '--reports=n'],
['pylint', './examples/minimal_config', '--reports=n', '--disable=I0011'],
['pylint', './examples/test_cli', '--reports=n'],
['pylint', './examples/example', '--reports=n', '--disable=I0011,E1101'],
['pylint', './examples/minimal_logging', '--reports=n',
'--disable=I0011,E1101'],
['pylint', './examples/stopwatch', '--reports=n', '--disable=I0011,E1101'],
['pylint', './examples/numbers', '--reports=n'],
['pylint', './examples/optimize', '--reports=n', '--disable=I0011,E1101'],
['pylint', './examples/replicate', '--reports=n', '--disable=I0011,E1101'],
['pylint', './examples/memoize', '--reports=n', '--disable=I0011,E1101'],
['pylint', './examples/benchmarks', '--reports=n'],
]
"""List of checkers to run and their arguments
"""
if __name__ == "__main__":
try:
TIC = datetime.now()
CHECKERS_RUN = 0
ERROR = False
for checker in CHECKERS:
process = Popen(checker, stdout=PIPE)
sys.stdout.write('.')
sys.stdout.flush()
CHECKERS_RUN += 1
header = "Output from %s" % " ".join(checker)
output = process.communicate()
message = ""
for elem in output:
if elem is not None and not len(elem) == 0:
message += elem
ERROR = True
if not message == "":
print_blue(header) # pylint: disable=no-member
print_blue("=" * len(header)) # pylint: disable=no-member
print(message)
print_blue("=" * len(header)) # pylint: disable=no-member
TOC = datetime.now()
print("\n" + ''.join(['-']*70))
print("Ran %i checkers in %fs\n" % (CHECKERS_RUN,
(TOC - TIC).total_seconds()))
if not ERROR:
print("OK")
except KeyboardInterrupt:
pass