[general] Very minor refactoring
This commit is contained in:
parent
73d62d7ded
commit
353c47d76e
2 changed files with 3 additions and 12 deletions
|
@ -26,7 +26,6 @@ class print_usage(argparse.Action):
|
||||||
|
|
||||||
def print_modules(self):
|
def print_modules(self):
|
||||||
for m in bumblebee.module.modules():
|
for m in bumblebee.module.modules():
|
||||||
|
|
||||||
print("{}{}: ".format(self._indent, m.name()))
|
print("{}{}: ".format(self._indent, m.name()))
|
||||||
print textwrap.fill("About : {}".format(m.description()),
|
print textwrap.fill("About : {}".format(m.description()),
|
||||||
80, initial_indent=self._indent*2, subsequent_indent=self._indent*4)
|
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)
|
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:
|
if not name in self._store:
|
||||||
self._store[name] = default
|
self._store[name] = default
|
||||||
return self._store.get(name, default)
|
return self._store.get(name, default)
|
||||||
|
|
||||||
def store(self, name, value):
|
|
||||||
self._store[name] = value
|
|
||||||
|
|
||||||
def increase(self, name, limit, default):
|
def increase(self, name, limit, default):
|
||||||
self._store[name] += 1
|
self._store[name] += 1
|
||||||
if self._store[name] >= limit:
|
if self._store[name] >= limit:
|
||||||
self._store[name] = default
|
self._store[name] = default
|
||||||
return self._store[name]
|
return self._store[name]
|
||||||
|
|
||||||
def parameter(self, name, default):
|
|
||||||
# TODO
|
|
||||||
return default
|
|
||||||
|
|
||||||
def theme(self):
|
def theme(self):
|
||||||
return self._args.theme
|
return self._args.theme
|
||||||
|
|
||||||
def modules(self):
|
def modules(self):
|
||||||
return self._args.modules
|
return self._args.modules
|
||||||
|
|
||||||
|
|
||||||
def _parser(self):
|
def _parser(self):
|
||||||
parser = argparse.ArgumentParser(description="display system data in the i3bar")
|
parser = argparse.ArgumentParser(description="display system data in the i3bar")
|
||||||
parser.add_argument("-m", "--modules", nargs="+",
|
parser.add_argument("-m", "--modules", nargs="+",
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Theme:
|
||||||
self.begin()
|
self.begin()
|
||||||
|
|
||||||
def begin(self):
|
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._cycle = self._cycles[0] if len(self._cycles) > 0 else {}
|
||||||
self._background = [ None, None ]
|
self._background = [ None, None ]
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class Theme:
|
||||||
|
|
||||||
if type(value) is list:
|
if type(value) is list:
|
||||||
key = "{}{}".format(repr(widget), value)
|
key = "{}{}".format(repr(widget), value)
|
||||||
idx = self._config.getstore(key, 0)
|
idx = self._config.parameter(key, 0)
|
||||||
self._config.increase(key, len(value), 0)
|
self._config.increase(key, len(value), 0)
|
||||||
value = value[idx]
|
value = value[idx]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue