khard.query
¶
Queries to match against contacts
Module Contents¶
Classes¶
A query to match against strings, lists of strings and CarddavObjects |
|
The null-query, it matches nothing. |
|
The match-anything-query, it always matches. |
|
A query to match an object against a fixed string. |
|
A query to match against a certain field in a carddav object. |
|
A query to combine multible queries with “and”. |
|
A query to combine multible queries with “or”. |
|
special query to match any kind of name field of a vcard |
Functions¶
|
Parse a string into a query object |
-
class
khard.query.
Query
¶ A query to match against strings, lists of strings and CarddavObjects
-
abstract
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
abstract
get_term
(self) → Optional[str]¶ Extract the search terms from a query.
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
abstract
-
class
khard.query.
NullQuery
¶ Bases:
khard.query.Query
The null-query, it matches nothing.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
get_term
(self) → None¶ Extract the search terms from a query.
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
AnyQuery
¶ Bases:
khard.query.Query
The match-anything-query, it always matches.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
get_term
(self) → str¶ Extract the search terms from a query.
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
TermQuery
(term: str)¶ Bases:
khard.query.Query
A query to match an object against a fixed string.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
get_term
(self) → str¶ Extract the search terms from a query.
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
FieldQuery
(field: str, value: str)¶ Bases:
khard.query.TermQuery
A query to match against a certain field in a carddav object.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
_match_union
(self, value: Union[str, datetime, List, Dict[str, Any]]) → bool¶
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
AndQuery
(first: Query, second: Query, *queries: Query)¶ Bases:
khard.query.Query
A query to combine multible queries with “and”.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
get_term
(self) → Optional[str]¶ Extract the search terms from a query.
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
OrQuery
(first: Query, second: Query, *queries: Query)¶ Bases:
khard.query.Query
A query to combine multible queries with “or”.
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
get_term
(self) → Optional[str]¶ Extract the search terms from a query.
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
class
khard.query.
NameQuery
(term: str)¶ Bases:
khard.query.TermQuery
special query to match any kind of name field of a vcard
-
match
(self, thing: Union[str, carddav_object.CarddavObject]) → bool¶ Match the self query against the given thing
-
__eq__
(self, other: object) → bool¶ A generic equality for all query types without parameters
-
__hash__
(self) → int¶ A generic hashing implementation for all queries without parameters
-
__str__
(self) → str¶ Return str(self).
-
-
khard.query.
parse
(string: str) → Union[TermQuery, FieldQuery]¶ Parse a string into a query object
The input string interpreted as a
FieldQuery
if it starts with a valid property name of theCarddavObject
class, followed by a colon and an arbitrary search term. Otherwise it is interpreted as aTermQuery
.- Parameters
string – a string to parse into a query
- Returns
a FieldQuery if the string contains a valid field specifier, a TermQuery otherwise