[modules/taskwarrior] update to latest API
This commit is contained in:
parent
cb4c561091
commit
7bdbdce087
1 changed files with 12 additions and 20 deletions
|
@ -7,38 +7,30 @@ Parameters:
|
|||
* taskwarrior.taskrc : path to the taskrc file (defaults to ~/.taskrc)
|
||||
"""
|
||||
|
||||
import bumblebee.input
|
||||
import bumblebee.output
|
||||
import bumblebee.engine
|
||||
|
||||
try:
|
||||
from taskw import TaskWarrior
|
||||
except:
|
||||
pass
|
||||
|
||||
import core.module
|
||||
import core.widget
|
||||
import core.decorators
|
||||
|
||||
class Module(bumblebee.engine.Module):
|
||||
"""TaskWarrior module."""
|
||||
class Module(core.module.Module):
|
||||
def __init__(self, config):
|
||||
super().__init__(config, core.widget.Widget(self.output))
|
||||
|
||||
def __init__(self, engine, config):
|
||||
"""Initialize taskwarrior module."""
|
||||
super(Module, self).__init__(engine, config,
|
||||
bumblebee.output.Widget(
|
||||
full_text=self.output))
|
||||
self._pending_tasks_count = '0'
|
||||
self.__pending_tasks = '0'
|
||||
|
||||
def update(self, widgets):
|
||||
def update(self):
|
||||
"""Return a string with the number of pending tasks from TaskWarrior."""
|
||||
try:
|
||||
taskrc = self.parameter('taskrc', '~/.taskrc')
|
||||
w = TaskWarrior(config_filename=taskrc)
|
||||
pending_tasks = w.filter_tasks({'status': 'pending'})
|
||||
self._pending_tasks_count = str(len(pending_tasks))
|
||||
self.__pending_tasks = str(len(pending_tasks))
|
||||
except:
|
||||
self._pending_tasks_count = 'Error'
|
||||
self.__pending_tasks = 'n/a'
|
||||
|
||||
def output(self, _):
|
||||
"""Format the task counter to output in bumblebee."""
|
||||
return '{}'.format(self._pending_tasks_count)
|
||||
return '{}'.format(self.__pending_tasks)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Reference in a new issue