From 250c0135e6565e755feb514574cd933193a287c0 Mon Sep 17 00:00:00 2001 From: Michael Skelton Date: Fri, 16 Jun 2017 16:51:27 +1000 Subject: [PATCH] added bumblebee module --- bumblebee/modules/todo.py | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bumblebee/modules/todo.py diff --git a/bumblebee/modules/todo.py b/bumblebee/modules/todo.py new file mode 100644 index 0000000..e51ff8f --- /dev/null +++ b/bumblebee/modules/todo.py @@ -0,0 +1,43 @@ +# pylint: disable=C0111,R0903 + +"""Displays the number of todo items in ~/Documents/todo.txt""" + +import platform + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + + +class Module(bumblebee.engine.Module): + + + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.output) + ) + self._todos = self.count_items() + + + def output(self, widget): + self._todos = self.count_items() + return self._todos + + + def state(self, widgets): + if self._todos == 0 : + return "empty" + return "items" + + + def count_items(filename): + try: + i=-1 + with open('/home/codingo/Documents/todo.txt') as f: + for i, l in enumerate(f): + pass + return i+1 + except Exception: + return 0 + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4