Merge pull request #225 from chdorb/master

[modules] add taskwarrior module
This commit is contained in:
tobi-wan-kenobi 2018-01-31 17:20:41 +01:00 committed by GitHub
commit 5b05db1023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View file

@ -13,6 +13,7 @@ install:
- pip install pyyaml
- pip install -U coverage==4.3
- pip install codeclimate-test-reporter
- pip install taskw
script:
- nosetests -v --with-coverage --cover-erase tests/
- CODECLIMATE_REPO_TOKEN=40cb00907f7a10e04868e856570bb997ab9c42fd3b63d980f2b2269433195fdf codeclimate-test-reporter

View file

@ -0,0 +1,39 @@
"""Displays the number of pending tasks in TaskWarrior.
Requires the following library:
* taskw
Parameters:
* taskwarrior.taskrc : path to the taskrc file (defaults to ~/.taskrc)
"""
import bumblebee.input
import bumblebee.output
import bumblebee.engine
from taskw import TaskWarrior
class Module(bumblebee.engine.Module):
"""TaskWarrior module."""
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"
def update(self, widgets):
"""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))
except:
self._pending_tasks_count = 'Error'
def output(self, _):
"""Format the task counter to ouptut in bumblebee."""
return "{}".format(self._pending_tasks_count)

BIN
screenshots/taskwarrior.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

View file

@ -132,5 +132,8 @@
"snow": { "prefix": "" },
"clear": { "prefix": "" },
"thunder": { "prefix": "" }
},
"taskwarrior": {
"prefix": "  "
}
}