File: lint.py

package info (click to toggle)
pcbasic 2.0.7-8
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 35,416 kB
  • sloc: python: 28,411; sh: 103; makefile: 10
file content (41 lines) | stat: -rwxr-xr-x 942 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3

from __future__ import print_function

import os
import sys

from pylint import epylint


CONFIG = [
    '--ignored-modules=pygame,numpy,pygame.mixer,msvcrt',
    '--ignored-classes=Serial,pygame.Surface,SimpleNamespace',
    '--errors-only',
]

if sys.version_info.major == 3:
    # this message just seems broken in py3 :/
    CONFIG += ['--disable=logging-too-many-args',]


def lint_files(path, filenames, exclude=()):
    for namext in filenames:
        name, ext = os.path.splitext(namext)
        if ext != '.py':
            continue
        if name in exclude:
            continue
        fullname = os.path.join(path, namext)
        print(fullname)
        epylint.lint(fullname, CONFIG)


basedir = os.path.join('..', 'pcbasic')

args = sys.argv[1:]
if not args or args == ['--all']:
    for path, _, filenames in os.walk(basedir):
        lint_files(path, filenames)
else:
    lint_files(basedir, args)