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 multiple queries with "and". |
|
A query to combine multiple 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: str | khard.carddav_object.CarddavObject) bool ¶
Match the self query against the given thing
- abstract get_term() str | None ¶
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:
Query
The null-query, it matches nothing.
- match(thing: 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:
Query
The match-anything-query, it always matches.
- match(thing: 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:
Query
A query to match an object against a fixed string.
- match(thing: 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:
TermQuery
A query to match against a certain field in a carddav object.
- match(thing: str | khard.carddav_object.CarddavObject) bool ¶
Match the self query against the given thing
- _match_union(value: 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:
Query
A query to combine multiple queries with “and”.
- match(thing: str | khard.carddav_object.CarddavObject) bool ¶
Match the self query against the given thing
- get_term() str | None ¶
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:
Query
A query to combine multiple queries with “or”.
- match(thing: str | khard.carddav_object.CarddavObject) bool ¶
Match the self query against the given thing
- get_term() str | None ¶
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:
TermQuery
special query to match any kind of name field of a vCard
- match(thing: 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:
FieldQuery
A special query to match against phone numbers.
- static _strip_phone_number(number: str) str ¶
- match(thing: str | khard.carddav_object.CarddavObject) bool ¶
Match the self query against the given thing
- _match_union(value: 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) 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