From 55474aadc38674d0ce55ea30054880a9993db4f3 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 4 Nov 2016 21:41:22 +0100 Subject: [PATCH] [general] Minor refactoring Shuffled some code around in an attempt to make it easier to read and understand. --- bumblebee-status | 7 +------ bumblebee/engine.py | 9 ++++----- bumblebee/output.py | 4 ++++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/bumblebee-status b/bumblebee-status index 0359142..97eef23 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -1,16 +1,11 @@ #!/usr/bin/env python -import bumblebee.theme import bumblebee.engine -import bumblebee.outputs.i3 def main(): args = bumblebee.engine.Arguments() - theme = bumblebee.theme.Theme(args.args()) - output = bumblebee.outputs.i3.Output(args.args()) - - engine = bumblebee.engine.Engine(args.args(), theme, output) + engine = bumblebee.engine.Engine(args.args()) engine.load_modules() engine.register_events() diff --git a/bumblebee/engine.py b/bumblebee/engine.py index 9c1aee4..07345cd 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -6,6 +6,7 @@ import textwrap import argparse import importlib import bumblebee.theme +import bumblebee.output class Arguments: def __init__(self): @@ -77,11 +78,11 @@ class Arguments: print "" class Engine: - def __init__(self, args, theme, output): + def __init__(self, args): self._modules = [] - self._output = output self._args = args - self._theme = theme + self._theme = bumblebee.theme.Theme(args) + self._output = bumblebee.output.output(args) def load_module(self, modulespec): name = modulespec.split(self._args.split)[0] @@ -106,11 +107,9 @@ class Engine: def register_events(self): for e in self._args.events: self.register_event(e) - pass def run(self): print self._output.start() - sys.stdout.flush() while True: # improve this diff --git a/bumblebee/output.py b/bumblebee/output.py index 9ed918b..2e75a99 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -1,5 +1,9 @@ import threading +def output(args): + import bumblebee.outputs.i3 + return bumblebee.outputs.i3.Output(args) + class Output(object): def __init__(self, args): self._callbacks = {}