Task¶
-
class
knut.apis.Task(task_dir='~/.local/share/knut/tasks')¶ Interact with the task service.
This class extends the
KnutAPIto handle the following requests:All tasks are stored in
tasks. Usingload_tasks(), the dictionary can be filled with tasks that are stored in the local directorytask_dir.Here’s a small example on how to create a new task:
>>> from knut.apis import Task >>> task_api = Task() >>> # since no id is an emtpy string, my_task will be as a new task >>> my_task = { >>> 'assignee': 'John', >>> 'author': 'Bob', >>> 'body': 'Can you please get some cheese at the supermarket.', >>> 'title': 'Buy cheese', >>> 'id': '' >>> } >>> task_api.request_handler(Task.TASK_RESPONSE, my_task)
In the example is no directory specified. Therefore, the task would not be saved by the task service.
-
load_tasks(task_dir=None)¶ Load all tasks saved in the directory task_dir.
If task_dir is not provided, the tasks from the directory
task_dirare loaded instead.
-
task_dir= None¶ The directory where the tasks are saved.
-
tasks= None¶ A dictionary with all back-ends.
The keys are the task identifier and the values are the corresponding
Taskobjects.
-