|
30 | 30 | from inspire_query_parser import parser |
31 | 31 | from inspire_query_parser.ast import (AndOp, EmptyQuery, ExactMatchValue, |
32 | 32 | GreaterEqualThanOp, GreaterThanOp, |
| 33 | + GreaterThanDateOp,LessThanDateOp, |
33 | 34 | Keyword, KeywordOp, LessEqualThanOp, |
34 | 35 | LessThanOp, MalformedQuery, |
35 | 36 | NestedKeywordOp, NotOp, OrOp, |
|
354 | 355 | # G, GE, LT, LE, E queries |
355 | 356 | ( |
356 | 357 | 'date > 2000-10 and date < 2000-12', |
357 | | - AndOp( |
358 | | - KeywordOp(Keyword('date'), GreaterThanOp(Value('2000-10'))), |
359 | | - KeywordOp(Keyword('date'), LessThanOp(Value('2000-12'))) |
360 | | - ) |
| 358 | + AndOp(KeywordOp(Keyword('date'), GreaterThanDateOp(Value('2000-10'))), KeywordOp(Keyword('date'), LessThanOp(Value('2000-12')))) |
361 | 359 | ), |
362 | 360 | ( |
363 | 361 | 'date after 10/2000 and date before 2000-12', |
364 | | - AndOp( |
365 | | - KeywordOp(Keyword('date'), GreaterThanOp(Value('10/2000'))), |
366 | | - KeywordOp(Keyword('date'), LessThanOp(Value('2000-12'))) |
367 | | - ) |
| 362 | + AndOp(KeywordOp(Keyword('date'), GreaterThanDateOp(Value('10/2000'))), KeywordOp(Keyword('date'), LessThanOp(Value('2000-12')))) |
368 | 363 | ), |
369 | 364 | ( |
370 | 365 | 'date >= nov 2000 and d<=2005', |
|
445 | 440 | 'du > yesterday - 2', |
446 | 441 | KeywordOp( |
447 | 442 | Keyword('date-updated'), |
448 | | - GreaterThanOp(Value(str((date.today() - relativedelta(days=3))))) |
| 443 | + GreaterThanDateOp(Value(str((date.today() - relativedelta(days=3))))) |
449 | 444 | ) |
450 | 445 | ), |
451 | 446 |
|
452 | 447 | # Wildcard queries |
453 | | - ( |
454 | | - 'find a \'o*aigh\' and t "alge*" and date >2013', |
455 | | - AndOp( |
456 | | - KeywordOp(Keyword('author'), PartialMatchValue('o*aigh', contains_wildcard=True)), |
457 | | - AndOp( |
458 | | - KeywordOp(Keyword('title'), ExactMatchValue('alge*' |
459 | | -
|
460 | | - )), |
461 | | - KeywordOp(Keyword('date'), GreaterThanOp(Value('2013'))) |
462 | | - ) |
463 | | - ) |
464 | | - ), |
465 | 448 | ( |
466 | 449 | 'a *alge | a alge* | a o*aigh', |
467 | 450 | OrOp( |
|
476 | 459 | 'find texkey Hirata:1992*', |
477 | 460 | KeywordOp(Keyword('texkeys'), Value('Hirata:1992*', contains_wildcard=True)) |
478 | 461 | ), |
479 | | -
|
| 462 | + ( |
| 463 | + "find a 'o*aigh' and t \"alge*\" and date >2013", |
| 464 | + AndOp( |
| 465 | + KeywordOp( |
| 466 | + Keyword("author"), |
| 467 | + PartialMatchValue("o*aigh", contains_wildcard=True), |
| 468 | + ), |
| 469 | + AndOp( |
| 470 | + KeywordOp(Keyword("title"), ExactMatchValue("alge*")), |
| 471 | + KeywordOp(Keyword("date"), GreaterThanDateOp(Value("2013"))), |
| 472 | + ), |
| 473 | + ), |
| 474 | + ), |
480 | 475 | # Queries for implicit "and" removal |
481 | 476 | ('title and foo', AndOp(ValueOp(Value('title')), ValueOp(Value('foo')))), |
482 | 477 | ('author takumi doi', KeywordOp(Keyword('author'), Value('takumi doi'))), |
@@ -711,7 +706,7 @@ def test_foo_bar(): |
711 | 706 | ) |
712 | 707 | ), |
713 | 708 | ('find cc italy', KeywordOp(Keyword('country'), Value('italy'))), |
714 | | - ('fin date > today', KeywordOp(Keyword('date'), GreaterThanOp(Value(str(date.today()))))), |
| 709 | + ('fin date > today', KeywordOp(Keyword('date'), GreaterThanDateOp(Value(str(date.today()))))), |
715 | 710 | ('find r atlas-conf-*', KeywordOp(Keyword('reportnumber'), Value('atlas-conf-*', contains_wildcard=True))), |
716 | 711 | ( |
717 | 712 | 'find caption "Diagram for the fermion flow violating process"', |
|
0 commit comments