From d62258c89d4a7b0ec8ecce3e835d7efa5537684b Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 4 Nov 2016 21:03:12 +0100 Subject: [PATCH] [all] Major refactoring Introduce an "Engine" class to abstract some of the details of loading modules, registering events, etc. --- bumblebee-status | 110 +++---------------------------------- bumblebee/engine.py | 118 ++++++++++++++++++++++++++++++++++++++++ bumblebee/output.py | 10 +--- bumblebee/outputs/i3.py | 9 ++- bumblebee/theme.py | 4 +- 5 files changed, 135 insertions(+), 116 deletions(-) create mode 100644 bumblebee/engine.py diff --git a/bumblebee-status b/bumblebee-status index ff1631f..0359142 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -1,114 +1,20 @@ #!/usr/bin/env python -import os -import sys -import time -import glob -import pkgutil -import argparse -import textwrap -import threading -import importlib import bumblebee.theme -import bumblebee.modules +import bumblebee.engine import bumblebee.outputs.i3 -def print_module_list(): - print "available modules:" - path = os.path.dirname(bumblebee.modules.__file__) - for mod in [ name for _, name, _ in pkgutil.iter_modules([path])]: - m = importlib.import_module("bumblebee.modules.{}".format(mod)) - - desc = "n/a" if not hasattr(m, "description") else getattr(m, "description")() - usage = "n/a" if not hasattr(m, "usage") else getattr(m, "usage")() - notes = "n/a" if not hasattr(m, "notes") else getattr(m, "notes")() - - print " {}: ".format(mod) - print textwrap.fill("Description: {}".format(desc), - 80, initial_indent=" ", subsequent_indent=" ") - print textwrap.fill("Usage : {}".format(usage), - 80, initial_indent=" ", subsequent_indent=" ") - print textwrap.fill("Notes : {}".format(notes), - 80, initial_indent=" ", subsequent_indent=" ") - print "" - -def print_theme_list(): - d = bumblebee.theme.getpath() - - print "available themes:" - print textwrap.fill(", ".join( - [ os.path.basename(f).replace(".json", "") for f in glob.iglob("{}/*.json".format(d)) ]), - 80, initial_indent = " ", subsequent_indent = " " - ) - -def init_argument_parser(): - parser = argparse.ArgumentParser(description="display system data in the i3bar") - parser.add_argument("-m", "--modules", nargs="+", help="List of modules to load. The order of the list determines their order in the i3bar (from left to right)", default=[]) - parser.add_argument("-e", "--events", nargs="+", help="List of click events that should be handled. Format is: