1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
23
# depends on pep8, pyflakes, pylint
26
# sudo apt-get install pylint pyflakes
28
# sudo apt-get install python-setuptools python-pip
29
# sudo pip install pep8
31
# in debian install pylint pyflakes pep8 with apt-get/aptitude/etc
34
# python release/test/pep8.py > pep8_error.txt 2>&1
36
# how many lines to read into the file, pep8 comment
37
# should be directly after the licence header, ~20 in most cases
38
PEP8_SEEK_COMMENT = 40
39
SKIP_PREFIX = "./tools", "./config", "./scons", "./extern"
42
def file_list_py(path):
43
for dirpath, dirnames, filenames in os.walk(path):
44
for filename in filenames:
45
if filename.endswith(".py"):
46
yield os.path.join(dirpath, filename)
51
for i in range(PEP8_SEEK_COMMENT):
53
if line.startswith("# <pep8"):
54
if line.startswith("# <pep8 compliant>"):
56
elif line.startswith("# <pep8-80 compliant>"):
65
for f in file_list_py("."):
66
pep8_type = is_pep8(f)
69
# so we can batch them for each tool.
70
files.append((os.path.abspath(f), pep8_type))
72
if not [None for prefix in SKIP_PREFIX if f.startswith(prefix)]:
75
print("\nSkipping...")
80
print("\n\n\n# running pep8...")
81
for f, pep8_type in files:
84
os.system("pep8 --repeat --ignore=E501 '%s'" % (f))
86
os.system("pep8 --repeat '%s'" % (f))
88
print("\n\n\n# running pyflakes...")
89
for f, pep8_type in files:
90
os.system("pyflakes '%s'" % f)
92
print("\n\n\n# running pylint...")
93
for f, pep8_type in files:
94
# let pep8 complain about line length
95
os.system("pylint --reports=n --max-line-length=1000 '%s'" % f)
97
if __name__ == "__main__":