2017-02-04 00:08:12 +00:00
|
|
|
from szurubooru.search.criteria import BaseCriterion
|
|
|
|
|
|
|
|
|
2016-10-22 12:43:52 +00:00
|
|
|
class AnonymousToken:
|
2017-02-04 00:08:12 +00:00
|
|
|
def __init__(self, criterion: BaseCriterion, negated: bool) -> None:
|
2016-06-03 10:13:43 +00:00
|
|
|
self.criterion = criterion
|
|
|
|
self.negated = negated
|
|
|
|
|
2017-02-04 00:08:12 +00:00
|
|
|
def __hash__(self) -> int:
|
2016-06-03 11:50:38 +00:00
|
|
|
return hash((self.criterion, self.negated))
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-06-03 10:13:43 +00:00
|
|
|
class NamedToken(AnonymousToken):
|
2017-02-04 00:08:12 +00:00
|
|
|
def __init__(
|
2020-06-05 22:03:37 +00:00
|
|
|
self, name: str, criterion: BaseCriterion, negated: bool
|
|
|
|
) -> None:
|
2016-06-03 10:13:43 +00:00
|
|
|
super().__init__(criterion, negated)
|
|
|
|
self.name = name
|
|
|
|
|
2017-02-04 00:08:12 +00:00
|
|
|
def __hash__(self) -> int:
|
2016-06-03 11:50:38 +00:00
|
|
|
return hash((self.name, self.criterion, self.negated))
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-10-22 12:43:52 +00:00
|
|
|
class SortToken:
|
2020-06-05 22:03:37 +00:00
|
|
|
SORT_DESC = "desc"
|
|
|
|
SORT_ASC = "asc"
|
|
|
|
SORT_NONE = ""
|
|
|
|
SORT_DEFAULT = "default"
|
|
|
|
SORT_NEGATED_DEFAULT = "negated default"
|
2016-06-03 10:13:43 +00:00
|
|
|
|
2017-02-04 00:08:12 +00:00
|
|
|
def __init__(self, name: str, order: str) -> None:
|
2016-06-03 10:13:43 +00:00
|
|
|
self.name = name
|
2016-08-14 12:22:53 +00:00
|
|
|
self.order = order
|
2016-06-03 10:13:43 +00:00
|
|
|
|
2017-02-04 00:08:12 +00:00
|
|
|
def __hash__(self) -> int:
|
2016-08-14 12:22:53 +00:00
|
|
|
return hash((self.name, self.order))
|
|
|
|
|
2016-06-03 11:50:38 +00:00
|
|
|
|
2016-10-22 12:43:52 +00:00
|
|
|
class SpecialToken:
|
2017-02-04 00:08:12 +00:00
|
|
|
def __init__(self, value: str, negated: bool) -> None:
|
2016-06-03 10:13:43 +00:00
|
|
|
self.value = value
|
|
|
|
self.negated = negated
|
2016-06-03 11:50:38 +00:00
|
|
|
|
2017-02-04 00:08:12 +00:00
|
|
|
def __hash__(self) -> int:
|
2016-06-03 11:50:38 +00:00
|
|
|
return hash((self.value, self.negated))
|