Merge pull request #274 from abdoulayeYATERA/fixTodoModulePathExpansion

fix todo module path expansion
This commit is contained in:
tobi-wan-kenobi 2018-07-01 05:44:51 +02:00 committed by GitHub
commit 66e9608b32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ Parameters:
import bumblebee.input import bumblebee.input
import bumblebee.output import bumblebee.output
import bumblebee.engine import bumblebee.engine
import os.path
class Module(bumblebee.engine.Module): class Module(bumblebee.engine.Module):
@ -18,6 +19,7 @@ class Module(bumblebee.engine.Module):
super(Module, self).__init__(engine, config, super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.output) bumblebee.output.Widget(full_text=self.output)
) )
self._doc = os.path.expanduser(self.parameter("file", "~/Documents/todo.txt"))
self._todos = self.count_items() self._todos = self.count_items()
@ -32,15 +34,12 @@ class Module(bumblebee.engine.Module):
return "items" return "items"
def count_items(filename): def count_items(self):
try: try:
i = -1 i = -1
doc = self.parameter("file", "~/Documents/todo.txt") with open(self._doc) as f:
with open(doc) as f:
for i, l in enumerate(f): for i, l in enumerate(f):
pass pass
return i+1 return i+1
except Exception: except Exception:
return 0 return 0
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4