Fix lint in scripts

This commit is contained in:
Florian Bruhin 2014-05-15 08:24:10 +02:00
parent 5de6084e50
commit 7f3a21e4f0
6 changed files with 26 additions and 15 deletions

View File

@ -0,0 +1 @@
"""Various scripts used to develop/install qutebrowser."""

View File

@ -32,14 +32,16 @@ lint = ['build', 'dist', 'pkg/pkg', 'pkg/qutebrowser-*.pkg.tar.xz', 'pkg/src',
'setuptools-*.zip']
def remove(path):
"""Remove either a file or directory unless --dry-run is given."""
if os.path.isdir(path):
print("rm -r '{}'".format(path))
if not '--dry-run' in sys.argv: shutil.rmtree(path)
if not '--dry-run' in sys.argv:
shutil.rmtree(path)
else:
print("rm '{}'".format(path))
if not '--dry-run' in sys.argv: os.remove(path)
if not '--dry-run' in sys.argv:
os.remove(path)
for elem in lint:

View File

@ -80,8 +80,8 @@ executable = Executable('qutebrowser/__main__.py', base=base,
try:
write_git_file()
setup(
executables = [executable],
options = {
executables=[executable],
options={
'build_exe': build_exe_options,
'bdist_msi': bdist_msi_options,
},

View File

@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=broad-except
""" Run different codecheckers over a codebase.
Runs flake8, pylint, pep257, a CRLF/whitespace/conflict-checker and pyroma by
@ -71,6 +73,7 @@ if os.name == 'nt':
# arrows in configdata.py
options['exclude_pep257'].append('configdata.py')
def run(name, target, args=None):
"""Run a checker via distutils with optional args.
@ -122,18 +125,20 @@ def check_pep257(target, args=None):
def check_unittest():
"""Run the unittest checker."""
print("==================== unittest ====================")
suite = unittest.TestLoader().discover('.')
result = unittest.TextTestRunner().run(suite)
print()
status['unittest'] = result.wasSuccessful()
def check_line(target):
"""Run _check_file over a filetree."""
print("------ line ------")
ret = []
try:
for (dirpath, dirnames, filenames) in os.walk(target):
for (dirpath, _dirnames, filenames) in os.walk(target):
for name in (e for e in filenames if e.endswith('.py')):
fn = os.path.join(dirpath, name)
ret.append(_check_file(fn))
@ -170,6 +175,7 @@ def _get_args(checker):
Return:
A list of commandline arguments.
"""
# pylint: disable=too-many-branches
args = []
if checker == 'pylint':
try:
@ -206,7 +212,7 @@ def _get_args(checker):
except KeyError:
pass
try:
args += ['--match=(?!{}).*\.py'.format('|'.join(
args += [r'--match=(?!{}).*\.py'.format('|'.join(
options['exclude'] + options['exclude_pep257']))]
except KeyError:
pass
@ -220,14 +226,14 @@ def _get_args(checker):
check_unittest()
for target in options['targets']:
print("==================== {} ====================".format(target))
for trg in options['targets']:
print("==================== {} ====================".format(trg))
if do_check_257:
check_pep257(target, _get_args('pep257'))
for checker in ['pylint', 'flake8', 'pyroma']:
check_pep257(trg, _get_args('pep257'))
for chk in ['pylint', 'flake8', 'pyroma']:
# FIXME what the hell is the flake8 exit status?
run(checker, target, _get_args(checker))
check_line(target, )
run(chk, trg, _get_args(chk))
check_line(trg, )
print("Exit status values:")
for (k, v) in status.items():

View File

@ -10,7 +10,7 @@ from shutil import rmtree
sys.path.insert(0, getcwd())
from qutebrowser.app import QuteBrowser
from qutebrowser.app import QuteBrowser # pylint: disable=unused-import
tempdir = mkdtemp()

View File

@ -16,7 +16,7 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Data used by setup.py and scripts/freeze.py"""
"""Data used by setup.py and scripts/freeze.py."""
import sys
import os
@ -34,6 +34,7 @@ except NameError:
def read_file(name):
"""Get the string contained in the file named name."""
with open(name, encoding='utf-8') as f:
return f.read()
@ -58,6 +59,7 @@ def _git_str():
def write_git_file():
"""Write the git-commit-id file with the current commit."""
gitstr = _git_str()
if gitstr is None:
gitstr = ''