[doc] update API docs
This commit is contained in:
parent
8ca036bc4c
commit
b4f8870a95
3 changed files with 72 additions and 2 deletions
|
@ -27,7 +27,11 @@ THEME_HELP = "Specify the theme to use for drawing modules"
|
|||
|
||||
|
||||
def all_modules():
|
||||
"""Return a list of available modules"""
|
||||
"""Returns a list of all available modules (either core or contrib)
|
||||
|
||||
:return: list of modules
|
||||
:rtype: list of strings
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for path in [modules.core.__file__, modules.contrib.__file__]:
|
||||
|
@ -127,6 +131,11 @@ class print_usage(argparse.Action):
|
|||
|
||||
|
||||
class Config(util.store.Store):
|
||||
"""Represents the configuration of bumblebee-status (either via config file or via CLI)
|
||||
|
||||
:param args: The arguments passed via the commandline
|
||||
"""
|
||||
|
||||
def __init__(self, args):
|
||||
super(Config, self).__init__()
|
||||
|
||||
|
@ -202,6 +211,11 @@ class Config(util.store.Store):
|
|||
key, value = param.split("=", 1)
|
||||
self.set(key, value)
|
||||
|
||||
"""Loads parameters from an init-style configuration file
|
||||
|
||||
:param filename: path to the file to load
|
||||
"""
|
||||
|
||||
def load_config(self, filename):
|
||||
if os.path.exists(filename):
|
||||
log.info("loading {}".format(filename))
|
||||
|
@ -212,27 +226,75 @@ class Config(util.store.Store):
|
|||
for key, value in tmp.items("module-parameters"):
|
||||
self.set(key, value)
|
||||
|
||||
"""Returns a list of configured modules
|
||||
|
||||
:return: list of configured (active) modules
|
||||
:rtype: list of strings
|
||||
"""
|
||||
|
||||
def modules(self):
|
||||
return [item for sub in self.__args.modules for item in sub]
|
||||
|
||||
"""Returns the global update interval
|
||||
|
||||
:return: update interval in seconds
|
||||
:rtype: float
|
||||
"""
|
||||
|
||||
def interval(self, default=1):
|
||||
return util.format.seconds(self.get("interval", default))
|
||||
|
||||
"""Returns whether debug mode is enabled
|
||||
|
||||
:return: True if debug is enabled, False otherwise
|
||||
:rtype: boolean
|
||||
"""
|
||||
|
||||
def debug(self):
|
||||
return self.__args.debug
|
||||
|
||||
"""Returns whether module order should be reversed/inverted
|
||||
|
||||
:return: True if modules should be reversed, False otherwise
|
||||
:rtype: boolean
|
||||
"""
|
||||
|
||||
def reverse(self):
|
||||
return self.__args.right_to_left
|
||||
|
||||
"""Returns the logfile location
|
||||
|
||||
:return: location where the logfile should be written
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
def logfile(self):
|
||||
return self.__args.logfile
|
||||
|
||||
"""Returns the configured theme name
|
||||
|
||||
:return: name of the configured theme
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
def theme(self):
|
||||
return self.__args.theme
|
||||
|
||||
"""Returns the configured iconset name
|
||||
|
||||
:return: name of the configured iconset
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
def iconset(self):
|
||||
return self.__args.iconset
|
||||
|
||||
"""Returns which modules should be hidden if their state is not warning/critical
|
||||
|
||||
:return: list of modules to hide automatically
|
||||
:rtype: list of strings
|
||||
"""
|
||||
|
||||
def autohide(self, name):
|
||||
return name in self.__args.autohide
|
||||
|
||||
|
|
|
@ -8,16 +8,20 @@ def discover():
|
|||
)
|
||||
sys.path.append(libdir)
|
||||
|
||||
|
||||
def utility(name):
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
for path in [
|
||||
os.path.join(current_path, "..", "bin"),
|
||||
os.path.join(current_path, "..", "..", "..", "..", "share", "bumblebee-status", "utility"),
|
||||
os.path.join(
|
||||
current_path, "..", "..", "..", "..", "share", "bumblebee-status", "utility"
|
||||
),
|
||||
"/usr/share/bumblebee-status/bin/",
|
||||
]:
|
||||
if os.path.exists(os.path.abspath(os.path.join(path, name))):
|
||||
return os.path.abspath(os.path.join(path, name))
|
||||
raise Exception("{} not found".format(name))
|
||||
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
|
@ -24,6 +24,7 @@ class HBar(Bar):
|
|||
|
||||
:param value: percentage value to draw (float, between 0 and 100)
|
||||
"""
|
||||
|
||||
def __init__(self, value):
|
||||
super(HBar, self).__init__(value)
|
||||
self.step = MAX_PERCENTS / len(HBar.bars)
|
||||
|
@ -69,6 +70,7 @@ class VBar(Bar):
|
|||
:param value: percentage value to draw (float, between 0 and 100)
|
||||
:param width: maximum width of the bar in characters
|
||||
"""
|
||||
|
||||
def __init__(self, value, width=1):
|
||||
super(VBar, self).__init__(value)
|
||||
self.step = MAX_PERCENTS / (len(VBar.bars) * width)
|
||||
|
@ -79,6 +81,7 @@ class VBar(Bar):
|
|||
:return: characters representing the value passed during initialization
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
def get_chars(self):
|
||||
if self.value == 100:
|
||||
return self.bars[-1] * self.width
|
||||
|
@ -146,6 +149,7 @@ class BrailleGraph(object):
|
|||
|
||||
:param values: values to draw
|
||||
"""
|
||||
|
||||
def __init__(self, values):
|
||||
self.values = values
|
||||
# length of values list must be even
|
||||
|
|
Loading…
Reference in a new issue