[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:
parent
9a5a6d354a
commit
a7eff64294
3 changed files with 38 additions and 21 deletions
|
@ -1,22 +1,35 @@
|
||||||
|
"""Configuration handling
|
||||||
|
|
||||||
|
This module provides configuration information (loaded modules,
|
||||||
|
module parameters, etc.) to all other components
|
||||||
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
MODULE_HELP = ""
|
MODULE_HELP = ""
|
||||||
|
|
||||||
|
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):
|
class Config(object):
|
||||||
def __init__(self, args = []):
|
"""Top-level configuration class
|
||||||
parser = self._create_parser()
|
|
||||||
self._args = parser.parse_args(args)
|
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):
|
def modules(self):
|
||||||
return list(map(lambda x: {
|
"""Return a list of all activated modules"""
|
||||||
|
return [{
|
||||||
"module": x.split(":")[0],
|
"module": x.split(":")[0],
|
||||||
"name": x if not ":" in x else x.split(":")[1]
|
"name": x if not ":" in x else x.split(":")[1],
|
||||||
}, self._args.modules))
|
} for x in self._args.modules]
|
||||||
|
|
||||||
def _create_parser(self):
|
|
||||||
parser = argparse.ArgumentParser(description="display system data in the i3bar")
|
|
||||||
parser.add_argument("-m", "--modules", nargs="+", default = [],
|
|
||||||
help = MODULE_HELP)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
3
runlint.sh
Executable file
3
runlint.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
find . -name "*.py"|xargs pylint
|
|
@ -1,3 +1,4 @@
|
||||||
|
# pylint: disable=C0103,C0111
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bumblebee.config import Config
|
from bumblebee.config import Config
|
||||||
|
@ -5,24 +6,24 @@ from bumblebee.config import Config
|
||||||
class TestConfig(unittest.TestCase):
|
class TestConfig(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.defaultConfig = Config()
|
self.defaultConfig = Config()
|
||||||
self.someSimpleModules = [ "foo", "bar", "baz" ]
|
self.someSimpleModules = ["foo", "bar", "baz"]
|
||||||
self.someAliasModules = [ "foo:a", "bar:b", "baz:c" ]
|
self.someAliasModules = ["foo:a", "bar:b", "baz:c"]
|
||||||
|
|
||||||
|
|
||||||
def test_no_modules_by_default(self):
|
def test_no_modules_by_default(self):
|
||||||
self.assertEquals(self.defaultConfig.modules(), [])
|
self.assertEquals(self.defaultConfig.modules(), [])
|
||||||
|
|
||||||
def test_load_simple_modules(self):
|
def test_load_simple_modules(self):
|
||||||
cfg = Config([ "-m" ] + self.someSimpleModules)
|
cfg = Config(["-m"] + self.someSimpleModules)
|
||||||
self.assertEquals(cfg.modules(), list(map(lambda x: {
|
self.assertEquals(cfg.modules(), [{
|
||||||
"name": x, "module": x
|
"name": x, "module": x
|
||||||
}, self.someSimpleModules)))
|
} for x in self.someSimpleModules])
|
||||||
|
|
||||||
def test_load_alias_modules(self):
|
def test_load_alias_modules(self):
|
||||||
cfg = Config([ "-m" ] + self.someAliasModules)
|
cfg = Config(["-m"] + self.someAliasModules)
|
||||||
self.assertEquals(cfg.modules(), list(map(lambda x: {
|
self.assertEquals(cfg.modules(), [{
|
||||||
"module": x.split(":")[0],
|
"module": x.split(":")[0],
|
||||||
"name": x.split(":")[1]
|
"name": x.split(":")[1],
|
||||||
}, self.someAliasModules)))
|
} for x in self.someAliasModules])
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue