[lint] Add tool to run pylint on all files

pylint all *.py files and fix the errors reported so far.
This commit is contained in:
Tobi-wan Kenobi 2016-12-04 08:02:40 +01:00
parent 9a5a6d354a
commit a7eff64294
3 changed files with 38 additions and 21 deletions

View file

@ -1,22 +1,35 @@
"""Configuration handling
This module provides configuration information (loaded modules,
module parameters, etc.) to all other components
"""
import argparse
MODULE_HELP = ""
class Config(object):
def __init__(self, args = []):
parser = self._create_parser()
self._args = parser.parse_args(args)
def modules(self):
return list(map(lambda x: {
"module": x.split(":")[0],
"name": x if not ":" in x else x.split(":")[1]
}, self._args.modules))
def _create_parser(self):
def create_parser():
"""Create the argument parser"""
parser = argparse.ArgumentParser(description="display system data in the i3bar")
parser.add_argument("-m", "--modules", nargs="+", default=[],
help=MODULE_HELP)
return parser
class Config(object):
"""Top-level configuration class
Parses commandline arguments and provides non-module
specific configuration information.
"""
def __init__(self, args=None):
parser = create_parser()
self._args = parser.parse_args(args if args else [])
def modules(self):
"""Return a list of all activated modules"""
return [{
"module": x.split(":")[0],
"name": x if not ":" in x else x.split(":")[1],
} for x in self._args.modules]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

3
runlint.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
find . -name "*.py"|xargs pylint

View file

@ -1,3 +1,4 @@
# pylint: disable=C0103,C0111
import unittest
from bumblebee.config import Config
@ -14,15 +15,15 @@ class TestConfig(unittest.TestCase):
def test_load_simple_modules(self):
cfg = Config(["-m"] + self.someSimpleModules)
self.assertEquals(cfg.modules(), list(map(lambda x: {
self.assertEquals(cfg.modules(), [{
"name": x, "module": x
}, self.someSimpleModules)))
} for x in self.someSimpleModules])
def test_load_alias_modules(self):
cfg = Config(["-m"] + self.someAliasModules)
self.assertEquals(cfg.modules(), list(map(lambda x: {
self.assertEquals(cfg.modules(), [{
"module": x.split(":")[0],
"name": x.split(":")[1]
}, self.someAliasModules)))
"name": x.split(":")[1],
} for x in self.someAliasModules])
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4