~gtg-user/gtg/documenters-credits

« back to all changes in this revision

Viewing changes to GTG/core/search.py

  • Committer: Izidor Matušov
  • Date: 2012-05-17 18:26:38 UTC
  • mfrom: (1175.1.14 fix-test-script)
  • Revision ID: izidor.matusov@gmail.com-20120517182638-i4jsjyo2bjhbe7ar
Merging huxan's fix so tests are working again and are mandatory to accept patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
Search feature for GTG
22
22
 
23
23
Created by:
24
 
  * João Ascenso, GSoC 2011
25
 
  * Izidor Matušov, Jan/Feb 2012
 
24
  - João Ascenso, GSoC 2011
 
25
  - Izidor Matušov, Jan/Feb 2012
26
26
 
27
27
You can search by entring a query in a simple language. Function
28
28
parse_search_query() parse the query and return internal representation which
30
30
the exception InvalidQuery is raised.
31
31
 
32
32
The query language consists of several elements:
33
 
  * commands
34
 
    * !not <elem> -- the next element will be negated
35
 
    * <elem> !or <elem> -- return True if at least on of elements is true
36
 
    * !after <date> -- show tasks which could be done after this date
37
 
    * !before <date> -- show tasks which must be done before this date
38
 
    * !today -- show tasks with due_date == today
39
 
    * !tomorrow -- show tasks with due_date == tomorrow
40
 
    * !nodate -- show tasks without due_date
41
 
    * !now -- show tasks with due_date == now
42
 
    * !soon -- show tasks with due_date == soon
43
 
    * !someday -- show tasks with due_date == someday
44
 
    * !notag -- show tasks without tags
45
 
  * tags -- show tasks with this tag
46
 
  * word -- show tasks which contains this word
47
 
  * "literal" -- basically the same as word but allows the space and special
 
33
  - commands
 
34
    - !not <elem> -- the next element will be negated
 
35
    - <elem> !or <elem> -- return True if at least on of elements is true
 
36
    - !after <date> -- show tasks which could be done after this date
 
37
    - !before <date> -- show tasks which must be done before this date
 
38
    - !today -- show tasks with due_date == today
 
39
    - !tomorrow -- show tasks with due_date == tomorrow
 
40
    - !nodate -- show tasks without due_date
 
41
    - !now -- show tasks with due_date == now
 
42
    - !soon -- show tasks with due_date == soon
 
43
    - !someday -- show tasks with due_date == someday
 
44
    - !notag -- show tasks without tags
 
45
  - tags -- show tasks with this tag
 
46
  - word -- show tasks which contains this word
 
47
  - "literal" -- basically the same as word but allows the space and special
48
48
        characters inside. Literal must be inside "quotes".
49
 
  * date -- date which could be parsed with Date.parse()
 
49
  - date -- date which could be parsed with Date.parse()
50
50
 
51
 
Elements are supposed to be in conjuction, i.e. they are interpreted as
52
 
 E1 AND E2 AND E3 AND E4 AND ( E5 OR E6 OR E7 ) AND E8 ...
 
51
Elements are supposed to be in conjuction, i.e. they are interpreted as::
 
52
  E1 AND E2 AND E3 AND E4 AND ( E5 OR E6 OR E7 ) AND E8 ...
53
53
 
54
54
Examples of queries:
55
55
'!tomorrow !or !today' => show tasks which are today or tomorrow
61
61
 
62
62
 
63
63
search_filter() expect parameter 'q' which is a list of commands in the form
64
 
(name_of_command, should_be_positive, arguments). If
 
64
(name_of_command, should_be_positive, arguments). If::
65
65
  should_be_positive == True => task has to satisfy this command
66
66
  should_be_positive == False => task must not satisfy this command
67
67
 
72
72
tasks.
73
73
 
74
74
For more information see unittests:
75
 
  * GTG/tests/test_search_query.py -- parsing query
76
 
  * GTG/tests/test_search_filter.py -- filtering a task
 
75
  - GTG/tests/test_search_query.py -- parsing query
 
76
  - GTG/tests/test_search_filter.py -- filtering a task
77
77
"""
78
78
 
79
79
import re