[general] Very minor refactoring

This commit is contained in:
Tobias Witek 2016-11-05 12:18:30 +01:00
parent 73d62d7ded
commit 353c47d76e
2 changed files with 3 additions and 12 deletions

View file

@ -26,7 +26,6 @@ class print_usage(argparse.Action):
def print_modules(self):
for m in bumblebee.module.modules():
print("{}{}: ".format(self._indent, m.name()))
print textwrap.fill("About : {}".format(m.description()),
80, initial_indent=self._indent*2, subsequent_indent=self._indent*4)
@ -48,31 +47,23 @@ class Config(object):
self._args = self._parser.parse_args(args)
def getstore(self, name, default=None):
def parameter(self, name, default=None):
if not name in self._store:
self._store[name] = default
return self._store.get(name, default)
def store(self, name, value):
self._store[name] = value
def increase(self, name, limit, default):
self._store[name] += 1
if self._store[name] >= limit:
self._store[name] = default
return self._store[name]
def parameter(self, name, default):
# TODO
return default
def theme(self):
return self._args.theme
def modules(self):
return self._args.modules
def _parser(self):
parser = argparse.ArgumentParser(description="display system data in the i3bar")
parser.add_argument("-m", "--modules", nargs="+",

View file

@ -19,7 +19,7 @@ class Theme:
self.begin()
def begin(self):
self._config.store("theme.cycleidx", 0)
self._config.parameter("theme.cycleidx", 0)
self._cycle = self._cycles[0] if len(self._cycles) > 0 else {}
self._background = [ None, None ]
@ -80,7 +80,7 @@ class Theme:
if type(value) is list:
key = "{}{}".format(repr(widget), value)
idx = self._config.getstore(key, 0)
idx = self._config.parameter(key, 0)
self._config.increase(key, len(value), 0)
value = value[idx]