[docs]classQuery(Generic[ConditionDataT]):r"""This class represents the query data sent from flow launcher .. container:: operations .. describe:: x == y Compare the keywords, text, and is_query values of two query objects. .. describe:: hash(x) Gets the hash of the query's raw text Attributes ---------- raw_text: :class:`str`: The raw and complete query, which includes the keyword is_requery: :class:`bool` Whether the query is a requery or not text: :class:`str` The actual query, excluding any keywords keyword: :class:`str` The keyword used to initiate the query """def__init__(self,data:RawQuery,plugin:PluginT)->None:self.__search_condition_data:ConditionDataT|None=Noneself._data=dataself.plugin=plugin@propertydefcondition_data(self)->ConditionDataT|None:""":class:`Any` | ``None``: If used in a :class:`~flogin.search_handler.SearchHandler`, this attribute will return any extra data that the condition gave."""returnself.__search_condition_data@condition_data.setterdefcondition_data(self,value:ConditionDataT)->None:self.__search_condition_data=value@propertydefis_requery(self)->bool:returnself._data["isReQuery"]@propertydefkeyword(self)->str:returnself._data["actionKeyword"]or"*"@propertydefraw_text(self)->str:returnself._data["rawQuery"]@propertydeftext(self)->str:returnself._data["search"]def__eq__(self,other:Any)->bool:return(isinstance(other,Query)andother.raw_text==self.raw_textandother.is_requery==self.is_requery)def__hash__(self)->int:returnhash(self.raw_text)def__repr__(self)->str:returnf"<Query {self.raw_text=}{self.text=}{self.keyword=}{self.is_requery=}{self.condition_data=}>"
[docs]asyncdefupdate_results(self,results:list[Result])->None:r"""|coro| Tells flow to change the results shown to the user, using the query from this query object. This method provides quick acess to :func:`flogin.flow.api.FlowLauncherAPI.update_results`. Because of that, this method will only take affect if the user has not changed the query. Parameters ---------- results: list[:class:`~flogin.jsonrpc.results.Result`] The new results Raises ------- :class:`~flogin.jsonrpc.errors.JsonRPCException` This is raised when an error happens with the JsonRPC pipe while attempting to call this API method. Returns ------- ``None`` """returnawaitself.plugin.api.update_results(self.raw_text,results)
[docs]asyncdefupdate(self,*,text:str|None=MISSING,keyword:str|None=MISSING,requery:bool=False,)->None:r"""|coro| Applies updates to the query with flow, and to this object. This method provides quick acess to :func:`flogin.flow.api.FlowLauncherAPI.change_query` Parameters ---------- text: Optional[:class:`str` | ``None``] The text that will be used with the query. .. versionchanged:: 2.0.0 ``text`` can now be ``None``, and is now optional keyword: Optional[:class:`str` | ``None``] The keyword that will be used with the query. Defaults to the pre-existing value of :attr:`Query.keyword`. Set this to ``None`` or ``*`` for no keyword to be used. requery: Optional[:class:`bool`] Whether or not to re-send a query request in the event that the new query is the same as the current query. Defaults to ``False`` Raises ------- :class:`~flogin.jsonrpc.errors.JsonRPCException` This is raised when an error happens with the JsonRPC pipe while attempting to call this API method. Returns -------- ``None`` """ifkeywordisnotMISSING:self._data["actionKeyword"]="*"ifkeywordisNoneelsekeywordiftextisnotMISSING:self._data["search"]=textor""self._data["rawQuery"]=(f"{''ifself.keyword=='*'elseself.keyword}{self.text}".strip())returnawaitself.plugin.api.change_query(self.raw_text,requery=requery)