• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# coding: utf-8
2from __future__ import unicode_literals, division, absolute_import, print_function
3
4import os
5
6from . import package_name, package_root
7
8import flake8
9if not hasattr(flake8, '__version_info__') or flake8.__version_info__ < (3,):
10    from flake8.engine import get_style_guide
11else:
12    from flake8.api.legacy import get_style_guide
13
14
15def run():
16    """
17    Runs flake8 lint
18
19    :return:
20        A bool - if flake8 did not find any errors
21    """
22
23    print('Running flake8 %s' % flake8.__version__)
24
25    flake8_style = get_style_guide(config_file=os.path.join(package_root, 'tox.ini'))
26
27    paths = []
28    for _dir in [package_name, 'dev', 'tests']:
29        for root, _, filenames in os.walk(_dir):
30            for filename in filenames:
31                if not filename.endswith('.py'):
32                    continue
33                paths.append(os.path.join(root, filename))
34    report = flake8_style.check_files(paths)
35    success = report.total_errors == 0
36    if success:
37        print('OK')
38    return success
39