gnomesearchclient package¶
Submodules¶
gnomesearchclient.client module¶
- class gnomesearchclient.client.Client(auth=None, blacklist=None)¶
Bases:
objectClass for interacting with the Gnome search providers.
- async connect()¶
- async disconnect()¶
- get_initial_result_sets(search_terms, timeout=30)¶
Query the search providers for a search term.
Functions as an async generator that yields results as the providers finish generating them. Should cancel any incomplete searches if the loop exits early or is manually cancelled.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of results.
- static get_subsearch_result_sets(previous_search_results, current_search_terms, additional_providers=None, timeout=30)¶
Refine the initial search after the user types in more characters in the search entry.
- Parameters:
previous_search_results (
Iterable[Result[list[str]]]) – List of the previous search results.current_search_terms (
list[str]) – Updated search terms.additional_providers (
Iterable[Provider]) – Any additional providers to manually get the initial results for.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of updated results.
- async init()¶
- class gnomesearchclient.client.ClientStateful(client)¶
Bases:
objectWraps the Client class and maintains state information between get results calls.
- clear_previous_results()¶
Clears the state information.
- Return type:
None
- async get_initial_result_sets(search_terms, timeout=30)¶
Query the search providers for a search term.
Functions as an async generator that yields results as the providers finish generating them. Should cancel any incomplete searches if the loop exits early or is manually cancelled.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of results.
- get_search_result_sets(search_terms, timeout=30)¶
Alias for the get_subsearch_result_sets function.
Using this and the clear_previous_results function the same functionality can be accomplished as using the get_initial and get_subsearch functions but without maintaining which function to use at which time.
For example, the clear function could be called when beginning a new session and then this function used exclusively for all subsequent searches.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]
- async get_subsearch_result_sets(current_search_terms, timeout=30)¶
Refine the initial search after the user types in more characters in the search entry. If the provider did not complete the first search it is restarted. Uses state information from previous searches to update the results.
- Parameters:
current_search_terms (
list[str]) – Updated search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
List of updated search results.
- async init()¶
gnomesearchclient.provider module¶
- class gnomesearchclient.provider.Provider(desktop_id, bus_name, object_path, bus)¶
Bases:
object- async activate_result(result_id, search_terms, timestamp)¶
Activates the result when the search result has been selected to open it in the application.
- Parameters:
result_id (
str) – Result ID to activate.search_terms (
list[str]) – Search terms.timestamp (
int) – Time the search was executed.
- Return type:
None
- property bus_name: str¶
- property desktop_id: str¶
- async get_initial_result_set(search_terms)¶
Query the search provider for a search term. Return a list of results from the provider.
The function is used to initiate a search. Results from the initial search can be passed to other functions to continue the search with further information.
- Parameters:
search_terms (
list[str]) – List of search terms. Generally space separated input search.- Return type:
list[str]- Returns:
List of results.
- async get_result_metas(result_ids)¶
Get detailed information about the results.
The result is a list of dictionaries, one for each input result_id.
- Parameters:
result_ids (
list[str]) – Result IDs of the previously completed searches.- Return type:
list[ResultMeta]- Returns:
List of dictionaries.
- async get_subsearch_result_set(previous_search_results, current_search_terms)¶
Refine the initial search after the user types in more characters in the search entry.
- Parameters:
previous_search_results (
list[str]) – List of the previous search results returned from this or theget_initial_result_set()function.current_search_terms (
list[str]) – Updated search terms.
- Return type:
list[str]- Returns:
List of updated search results.
- async init()¶
- Return type:
None
- async launch_search(search_terms, timestamp)¶
Display more results in the application.
- Parameters:
search_terms (
list[str]) – Search terms.timestamp (
int) – Time the search was executed.
- Return type:
None
- property object_path: str¶
- class gnomesearchclient.provider.ProviderInfo(desktop_id, bus_name, object_path)¶
Bases:
object-
bus_name:
str¶
-
desktop_id:
str¶
-
object_path:
str¶
-
bus_name:
- class gnomesearchclient.provider.ResultMeta¶
Bases:
TypedDictClass for the return type of the get_result_metas function.
“id”: the result ID
“name”: the display name for the result
“icon”: a serialized GIcon (see g_icon_serialize()), or alternatively,
“gicon”: a textual representation of a GIcon (see g_icon_to_string()), or alternatively,
“icon-data”: a tuple of type (iiibiiay) describing a pixbuf with width, height, rowstride, has-alpha, bits-per-sample, n-channels, and image data
“description”: an optional short description (1-2 lines)
“clipboardText”: an optional text to send to the clipboard on activation
-
clipboardText:
str¶
-
description:
str¶
-
gicon:
str¶
-
icon:
str¶
-
icon_data:
tuple[int,int,int,bool,int,int,bytes]¶
-
id:
str¶
-
name:
str¶
Module contents¶
- class gnomesearchclient.Client(auth=None, blacklist=None)¶
Bases:
objectClass for interacting with the Gnome search providers.
- async connect()¶
- async disconnect()¶
- get_initial_result_sets(search_terms, timeout=30)¶
Query the search providers for a search term.
Functions as an async generator that yields results as the providers finish generating them. Should cancel any incomplete searches if the loop exits early or is manually cancelled.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of results.
- static get_subsearch_result_sets(previous_search_results, current_search_terms, additional_providers=None, timeout=30)¶
Refine the initial search after the user types in more characters in the search entry.
- Parameters:
previous_search_results (
Iterable[Result[list[str]]]) – List of the previous search results.current_search_terms (
list[str]) – Updated search terms.additional_providers (
Iterable[Provider]) – Any additional providers to manually get the initial results for.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of updated results.
- async init()¶
- class gnomesearchclient.ClientStateful(client)¶
Bases:
objectWraps the Client class and maintains state information between get results calls.
- clear_previous_results()¶
Clears the state information.
- Return type:
None
- async get_initial_result_sets(search_terms, timeout=30)¶
Query the search providers for a search term.
Functions as an async generator that yields results as the providers finish generating them. Should cancel any incomplete searches if the loop exits early or is manually cancelled.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
AsyncGenerator of results.
- get_search_result_sets(search_terms, timeout=30)¶
Alias for the get_subsearch_result_sets function.
Using this and the clear_previous_results function the same functionality can be accomplished as using the get_initial and get_subsearch functions but without maintaining which function to use at which time.
For example, the clear function could be called when beginning a new session and then this function used exclusively for all subsequent searches.
- Parameters:
search_terms (
list[str]) – List of search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]
- async get_subsearch_result_sets(current_search_terms, timeout=30)¶
Refine the initial search after the user types in more characters in the search entry. If the provider did not complete the first search it is restarted. Uses state information from previous searches to update the results.
- Parameters:
current_search_terms (
list[str]) – Updated search terms.timeout (
float) – Time to wait for provider before cancelling search.
- Return type:
AsyncGenerator[Result[list[str]],None]- Returns:
List of updated search results.
- async init()¶
- class gnomesearchclient.Provider(desktop_id, bus_name, object_path, bus)¶
Bases:
object- async activate_result(result_id, search_terms, timestamp)¶
Activates the result when the search result has been selected to open it in the application.
- Parameters:
result_id (
str) – Result ID to activate.search_terms (
list[str]) – Search terms.timestamp (
int) – Time the search was executed.
- Return type:
None
- property bus_name: str¶
- property desktop_id: str¶
- async get_initial_result_set(search_terms)¶
Query the search provider for a search term. Return a list of results from the provider.
The function is used to initiate a search. Results from the initial search can be passed to other functions to continue the search with further information.
- Parameters:
search_terms (
list[str]) – List of search terms. Generally space separated input search.- Return type:
list[str]- Returns:
List of results.
- async get_result_metas(result_ids)¶
Get detailed information about the results.
The result is a list of dictionaries, one for each input result_id.
- Parameters:
result_ids (
list[str]) – Result IDs of the previously completed searches.- Return type:
list[ResultMeta]- Returns:
List of dictionaries.
- async get_subsearch_result_set(previous_search_results, current_search_terms)¶
Refine the initial search after the user types in more characters in the search entry.
- Parameters:
previous_search_results (
list[str]) – List of the previous search results returned from this or theget_initial_result_set()function.current_search_terms (
list[str]) – Updated search terms.
- Return type:
list[str]- Returns:
List of updated search results.
- async init()¶
- Return type:
None
- async launch_search(search_terms, timestamp)¶
Display more results in the application.
- Parameters:
search_terms (
list[str]) – Search terms.timestamp (
int) – Time the search was executed.
- Return type:
None
- property object_path: str¶
- class gnomesearchclient.ProviderInfo(desktop_id, bus_name, object_path)¶
Bases:
object-
bus_name:
str¶
-
desktop_id:
str¶
-
object_path:
str¶
-
bus_name:
- class gnomesearchclient.Result(search_provider, query, results=None, error=None)¶
Bases:
Generic[T]-
error:
Optional[Exception] = None¶
-
query:
list[str]¶
-
results:
Optional[TypeVar(T)] = None¶
- property succeeded: bool¶
-
error:
- class gnomesearchclient.ResultMeta¶
Bases:
TypedDictClass for the return type of the get_result_metas function.
“id”: the result ID
“name”: the display name for the result
“icon”: a serialized GIcon (see g_icon_serialize()), or alternatively,
“gicon”: a textual representation of a GIcon (see g_icon_to_string()), or alternatively,
“icon-data”: a tuple of type (iiibiiay) describing a pixbuf with width, height, rowstride, has-alpha, bits-per-sample, n-channels, and image data
“description”: an optional short description (1-2 lines)
“clipboardText”: an optional text to send to the clipboard on activation
-
clipboardText:
str¶
-
description:
str¶
-
gicon:
str¶
-
icon:
str¶
-
icon_data:
tuple[int,int,int,bool,int,int,bytes]¶
-
id:
str¶
-
name:
str¶