weboob_lint.py 1.54 KB
Newer Older
1
#!/usr/bin/env python3
2
from __future__ import print_function
Christophe Benz's avatar
Christophe Benz committed
3

4
5
6
7
8
9
import logging
import os
import sys

from weboob.core import Weboob

10
11
12
# Hint: use this script with file:///path/to/local/modules/ in sources.list
# if you want to correctly check all modules.

13
14

logging.basicConfig()
Christophe Benz's avatar
Christophe Benz committed
15

16
17
weboob = Weboob()
weboob.modules_loader.load_all()
Romain Bignon's avatar
Romain Bignon committed
18

19
20
modules_without_tests = []
modules_without_icons = []
21
22
23
modules_without_py3 = []

with open(os.path.join(os.path.dirname(__file__), 'py3-compatible.modules')) as p:
24
    modules_py3_compatible = [m.strip()
25
26
27
                              for m in p.readlines()
                              if not m.startswith('#')]

28

29
30
for name, module in weboob.modules_loader.loaded.items():
    path = module.package.__path__[0]
31
    if not os.path.exists(os.path.join(path, 'test.py')):
32
        modules_without_tests.append(name)
33
34
    if not os.path.exists(os.path.join(path, 'favicon.png')) and \
       not os.path.exists(os.path.join(weboob.repositories.icons_dir, '%s.png' % name)) and \
35
36
       not module.icon:
        modules_without_icons.append(name)
37

38
    if name not in modules_py3_compatible:
39
        modules_without_py3.append(name)
40
41


42
43
44
45
if modules_without_tests:
    print('\nModules without tests: %s' % ', '.join(sorted(modules_without_tests)))
if modules_without_icons:
    print('\nModules without icons: %s' % ', '.join(sorted(modules_without_icons)))
46
47
if modules_without_py3:
    print('\nModules for Python 2 only: %s' % ', '.join(sorted(modules_without_py3)))
48

49

50
if modules_without_tests or modules_without_icons or modules_without_py3:
51
    sys.exit(1)