GothenburgBitFactory / tasklib

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

Bug when combining certain filters in raw commands? #39

Closed niknow closed 8 years ago

niknow commented 8 years ago

Hi,

I was trying out the following script with TaskWarrior 2.4.4. and tasklib 0.10.0 in Python 3.4:

import tasklib.task

# assume this TaskWarrior consists only of a 
# single task 'clean house' with id:1 and project:'foo'
tw = tasklib.task.TaskWarrior('local')

task = tw.tasks.filter('1')                
print(task) # gives: [clean house]

task = tw.tasks.filter('pro:foo')
print(task) # gives: [clean house]

task = tw.tasks.filter('1 pro:foo')
print(task) # gives: []

Should'nt the last one also return the task? The command line behaviour is exactly as expected:

task 1  # gives: [clean house]
task pro:foo # gives: [clean house]
task 1 pro:foo # gives:[clean house]

To make things worse: If we now set the priority of the task to H and run

import tasklib.task
tw = tasklib.task.TaskWarrior('local')
task = tw.tasks.filter('pro:foo')
print(task) # gives: [clean house]
task = tw.tasks.filter('pri:H')
print(task) # gives: [clean house]
task = tw.tasks.filter('pri:H  pro:foo')
print(task) # crashes: The expression could not be evaluated.
tbabej commented 8 years ago

You should separate the arguments as follows:

tw.tasks.filter('1', 'pro:foo')
tw.tasks.filter('pri:H', 'pro:foo')

Otherwise the corresponding task commands are:

$ task "1 pro:foo"
$ task "pri:H pro:foo"

and not:

$ task 1 pro:foo
$ task pri:H pro:foo
niknow commented 8 years ago

This is indeed the reason. Thanks for quickly resolving this issue so easily. ;)

tbabej commented 8 years ago

Well, the code was already there, all I did was point you to the right direction :)