findmy.util¶
Utility functions and classes. Intended for internal use.
Submodules¶
Classes¶
Response of a request made by HttpSession. |
|
Asynchronous HTTP session manager. For internal use only. |
Functions¶
|
Decode a plist file. |
Package Contents¶
- class findmy.util.HttpResponse(status_code: int, content: bytes)¶
Response of a request made by HttpSession.
- property status_code: int¶
HTTP status code of the response.
- property ok: bool¶
Whether the status code is “OK” (2xx).
- text() str ¶
Response content as a UTF-8 encoded string.
- json() dict[Any, Any] ¶
Response content as a dict, obtained by JSON-decoding the response content.
- plist() dict[Any, Any] ¶
Response content as a dict, obtained by Plist-decoding the response content.
- class findmy.util.HttpSession¶
Bases:
findmy.util.closable.Closable
Asynchronous HTTP session manager. For internal use only.
- async close() None ¶
Close the underlying session. Should be called when session will no longer be used.
- async request(method: str, url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) HttpResponse ¶
Make an HTTP request.
Keyword arguments will directly be passed to aiohttp.ClientSession.request.
- async get(url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) HttpResponse ¶
Alias for HttpSession.request(“GET”, …).
- async post(url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) HttpResponse ¶
Alias for HttpSession.request(“POST”, …).
- findmy.util.decode_plist(data: bytes) Any ¶
Decode a plist file.