-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheck.py
executable file
·67 lines (57 loc) · 2.09 KB
/
check.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
62
63
64
65
66
67
#!/usr/bin/env python2
# Wall
"""Run the Wall code quality checks."""
# Python forward compatibility
from __future__ import (division, absolute_import, print_function,
unicode_literals)
import sys
from unittest import TextTestRunner, defaultTestLoader
from pylint.lint import PyLinter
from wall.lib.checkre import (
checkre, line_length_check, simple_indentation_check, trailing_space_check,
header_check, whitespace_check, newline_at_eof_check)
def main():
"""Run the Wall code quality checks."""
print('Running unit tests...')
# TODO: tests = defaultTestLoader.discover('.')
tests = defaultTestLoader.loadTestsFromNames(
['wall', 'wall.util', 'wall.bricks.url'])
test_result = TextTestRunner(stream=sys.stdout).run(tests)
print('\nLinting (Python)...')
linter = PyLinter()
linter.load_default_plugins()
linter.load_file_configuration()
linter.load_configuration(ignore='lib')
# TODO: linter.check(['wall', 'walld.py', 'sjmpc.py', 'check.py'])
linter.check(['wall.util', 'walld.py', 'check.py'])
print('\nLinting (text)...')
checkre_result = checkre({
(
r'(?!.*/lib/).*\.(html|css)',
r'wall/res/default.cfg',
r'wall/res/static/(display|remote)/config.default.json',
r'pylintrc'
): (
line_length_check(),
simple_indentation_check(),
trailing_space_check(),
whitespace_check(),
newline_at_eof_check()
),
r'(?!.*/lib/).*\.md': (
line_length_check(),
trailing_space_check(),
whitespace_check(),
newline_at_eof_check()
),
r'(?!.*/lib/|walld.py|sjmpc.py|check.py).*\.py':
header_check('wall/__init__.py', 2),
r'(?!.*/lib/).*\.js': header_check('wall/res/static/wall.js', 4)
})
if (not test_result.wasSuccessful() or linter.msg_status != 0
or checkre_result != 0):
return 1
print('\nEverything looks fine, good work!')
return 0
if __name__ == '__main__':
sys.exit(main())