![]() Those two arguments are then passed in that order to the class' _init_ method. In the block above, the parse_uri method returns either (location,) or (location, key), if the key is present in the URI. Return ( location, query_string)ĭef _init_( self, location: str, api_key: str): # key can be passed in the URI or via connection arguments if "key" in query_string: The easiest way to do that is by defining a dummy method parse_uri that simply returns the URI to our class' _init_ staticmethod def parse_uri( uri: str) -> Union, Tuple]: The next step is instructing Shillelagh how to instantiate our class from the URI. ![]() On this second pass adapters can perform expensive operations, performing network requests to instrospect the URI and gather more information. If no adapters return True on the first pass, a second pass is performed with fast=False. If your adapter needs to perform costy operations to determine if it supports a given URI it should return None in this first pass, to indicate that it may support the URI. When this happens, adapter should return an optional boolean quickly. Adapter discovery is done in 2 phases: first all adapters have their supports method called with fast=True. Note that the supports method takes a parameter called fast. path = "/v1/history.json" and "q" in query_string and ( "key" in query_string or "api_key" in kwargs) Staticmethod def supports( uri: str, fast: bool = True, ** kwargs: Any) -> Optional:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |