GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
147 stars 28 forks source link

Looking at original and modified for on-modified hook. #32

Closed Doctor-Andonuts closed 9 years ago

Doctor-Andonuts commented 9 years ago

I would like to see if a task went from pending to completed (not just that it is completed because I do not want it to trigger if I modify an already completed task).

I am using task = Task.from_input() to collect the data but I do not see in the documentation how to compare or get values from the original task and compare them against the modified task. Perhaps you already have this implemented I didn't see how to do it.

Thanks for your time.

tbabej commented 9 years ago

You are correct, we currently do not have public, documented to access the original values in the Task object.

That said, you can look into original values pretty easily by accessing the _original_data dict:

task = Task.from_input()
if task._original_data['status'] is 'pending' and task['status'] is 'completed':
    <do your stuff>
tbabej commented 9 years ago

I'll leave this open as a reminder to wrap access to _original_data data dict in a public property and document it in the docs.

Doctor-Andonuts commented 9 years ago

Thanks you for the prompt response, this looks like exactly what I was looking for! This library makes it much easier to write hooks.

tbabej commented 9 years ago

Fixed with: 80230e4e58118eaec09b0a83459b8543fbf78260