File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed
Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -79,13 +79,13 @@ def __init__(
7979 def selects (self , * , record_dict : dict ) -> bool :
8080 """Indicates whether the query selects a given record."""
8181
82- if self .value == " NOT" :
82+ if self .value == Operators . NOT :
8383 return not self .children [0 ].selects (record_dict = record_dict )
8484
85- if self .value == " AND" :
85+ if self .value == Operators . AND :
8686 return all (x .selects (record_dict = record_dict ) for x in self .children )
8787
88- if self .value == "OR" :
88+ if self .value == Operators . OR :
8989 return any (x .selects (record_dict = record_dict ) for x in self .children )
9090
9191 assert not self .operator
Original file line number Diff line number Diff line change 66
77from search_query .constants import PLATFORM
88from search_query .constants import PLATFORM_FIELD_MAP
9-
9+ from search_query . constants import Operators
1010if typing .TYPE_CHECKING : # pragma: no
1111 from search_query .query import Query
1212
@@ -41,7 +41,7 @@ def to_string_pubmed(node: Query) -> str:
4141
4242 else :
4343 # node is operator node
44- if child .value == " NOT" :
44+ if child .value == Operators . NOT :
4545 # current element is NOT Operator -> no parenthesis in PubMed
4646 result = f"{ result } { to_string_pubmed (child )} "
4747
@@ -50,7 +50,7 @@ def to_string_pubmed(node: Query) -> str:
5050 else :
5151 result = f"{ result } { node .value } { to_string_pubmed (child )} "
5252
53- if (child == node .children [- 1 ]) & (child .value != " NOT" ):
53+ if (child == node .children [- 1 ]) & (child .value != Operators . NOT ):
5454 result = f"{ result } )"
5555 return f"{ result } "
5656
Original file line number Diff line number Diff line change 55import typing
66
77from search_query .constants import Fields
8+ from search_query .constants import Operators
89
910if typing .TYPE_CHECKING : # pragma: no
1011 from search_query .query import Query
@@ -36,7 +37,7 @@ def to_string_wos(node: Query) -> str:
3637
3738 else :
3839 # node is operator node
39- if child .value == " NOT" :
40+ if child .value == Operators . NOT :
4041 # current element is NOT Operator -> no parenthesis in WoS
4142 result = f"{ result } { to_string_wos (child )} "
4243
@@ -45,7 +46,7 @@ def to_string_wos(node: Query) -> str:
4546 else :
4647 result = f"{ result } { node .value } { to_string_wos (child )} "
4748
48- if (child == node .children [- 1 ]) & (child .value != " NOT" ):
49+ if (child == node .children [- 1 ]) & (child .value != Operators . NOT ):
4950 result = f"{ result } )"
5051 return f"{ result } "
5152
You can’t perform that action at this time.
0 commit comments