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 |
|
A special query to match against phone numbers. |
Functions¶
|
Parse a string into a query object |
Attributes¶
- khard.query.FIELD_PHONE_NUMBERS = phone_numbers¶
- class khard.query.Query¶
A query to match against strings, lists of strings and CarddavObjects
- abstract match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- abstract get_term() Optional[str]¶
Extract the search terms from a query.
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- class khard.query.NullQuery¶
Bases:
QueryThe null-query, it matches nothing.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- get_term() None¶
Extract the search terms from a query.
- __str__() str¶
Return str(self).
- class khard.query.AnyQuery¶
Bases:
QueryThe match-anything-query, it always matches.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- get_term() str¶
Extract the search terms from a query.
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.TermQuery(term: str)¶
Bases:
QueryA query to match an object against a fixed string.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- get_term() str¶
Extract the search terms from a query.
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.FieldQuery(field: str, value: str)¶
Bases:
TermQueryA query to match against a certain field in a carddav object.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- _match_union(value: Union[str, datetime.datetime, List, Dict[str, Any]]) bool¶
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.AndQuery(first: Query, second: Query, *queries: Query)¶
Bases:
QueryA query to combine multible queries with “and”.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- get_term() Optional[str]¶
Extract the search terms from a query.
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.OrQuery(first: Query, second: Query, *queries: Query)¶
Bases:
QueryA query to combine multible queries with “or”.
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- get_term() Optional[str]¶
Extract the search terms from a query.
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.NameQuery(term: str)¶
Bases:
TermQueryspecial query to match any kind of name field of a vcard
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() str¶
Return str(self).
- class khard.query.PhoneNumberQuery(value: str)¶
Bases:
FieldQueryA special query to match against phone numbers.
- static _strip_phone_number(number: str) str¶
- match(thing: Union[str, khard.carddav_object.CarddavObject]) bool¶
Match the self query against the given thing
- _match_union(value: Union[str, datetime.datetime, List, Dict[str, Any]]) bool¶
- _match_phone_number(number: str) bool¶
- __eq__(other: object) bool¶
A generic equality for all query types without parameters
- __hash__() int¶
A generic hashing implementation for all queries without parameters
- __str__() 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
FieldQueryif it starts with a valid property name of theCarddavObjectclass, 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