-
Notifications
You must be signed in to change notification settings - Fork 94
/
tox-check-plugin_registry.py
executable file
·69 lines (50 loc) · 1.54 KB
/
tox-check-plugin_registry.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
68
69
#!/usr/bin/env python
from __future__ import print_function
import textwrap
import sys
from infrared import PLUGINS_REGISTRY
def print_help():
print(textwrap.dedent("""
This tool checks that all plugin registry doesn't contain revision
for plugins.
./tox-check-plugin_registry.py [--help] ...
Loads plugins registry to test.
Any failing element will be printed to stdout as:
FAIL: plugin_name
In case of -v even it's yaml will be printed out (stderr).
"""))
def test_revision(plugins):
results = []
for elem in plugins:
if 'rev' in plugins[elem]:
elem_res = {'dict': elem}
results.append(elem_res)
return results
def clr(color, text, force=True):
if force or sys.stdout.isatty():
return '\033[%sm%s\033[0m' % (color, text)
else:
return text
def red(text):
return clr('1;31', text)
def print_out(results,):
for result in results:
print(red('FAIL: %s' % (result['dict'])))
def run_tests(plugins):
any_failure = False
try:
print('Validating plugins: %s ...' % plugins)
results = test_revision(plugins)
if len(results) != 0:
any_failure = True
print_out(results)
except:
print(red('ERROR: seems %s has revision.') % plugins)
any_failure = True
return any_failure
if __name__ == '__main__':
plugins = PLUGINS_REGISTRY
if '--help' in plugins:
print_help()
sys.exit(0)
sys.exit(int(run_tests(plugins)))