[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)
|
* taskwarrior.taskrc : path to the taskrc file (defaults to ~/.taskrc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import bumblebee.input
|
from taskw import TaskWarrior
|
||||||
import bumblebee.output
|
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
try:
|
import core.module
|
||||||
from taskw import TaskWarrior
|
import core.widget
|
||||||
except:
|
import core.decorators
|
||||||
pass
|
|
||||||
|
|
||||||
|
class Module(core.module.Module):
|
||||||
|
def __init__(self, config):
|
||||||
|
super().__init__(config, core.widget.Widget(self.output))
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
self.__pending_tasks = '0'
|
||||||
"""TaskWarrior module."""
|
|
||||||
|
|
||||||
def __init__(self, engine, config):
|
def update(self):
|
||||||
"""Initialize taskwarrior module."""
|
|
||||||
super(Module, self).__init__(engine, config,
|
|
||||||
bumblebee.output.Widget(
|
|
||||||
full_text=self.output))
|
|
||||||
self._pending_tasks_count = '0'
|
|
||||||
|
|
||||||
def update(self, widgets):
|
|
||||||
"""Return a string with the number of pending tasks from TaskWarrior."""
|
"""Return a string with the number of pending tasks from TaskWarrior."""
|
||||||
try:
|
try:
|
||||||
taskrc = self.parameter('taskrc', '~/.taskrc')
|
taskrc = self.parameter('taskrc', '~/.taskrc')
|
||||||
w = TaskWarrior(config_filename=taskrc)
|
w = TaskWarrior(config_filename=taskrc)
|
||||||
pending_tasks = w.filter_tasks({'status': 'pending'})
|
pending_tasks = w.filter_tasks({'status': 'pending'})
|
||||||
self._pending_tasks_count = str(len(pending_tasks))
|
self.__pending_tasks = str(len(pending_tasks))
|
||||||
except:
|
except:
|
||||||
self._pending_tasks_count = 'Error'
|
self.__pending_tasks = 'n/a'
|
||||||
|
|
||||||
def output(self, _):
|
def output(self, _):
|
||||||
"""Format the task counter to output in bumblebee."""
|
"""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
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue