Democritus functions[1] for working with network requests.
[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.
We use d8s
(pronounced "dee-eights") as an abbreviation for democritus
(you can read more about this here).
pip install d8s-networking
You import the library like:
from d8s_networking import *
Once imported, you can use any of the functions listed below.
-
def requests_basic_auth(user, password): """Return an instance of request's basic auth."""
-
def get( url, *, use_common_user_agent: bool = True, process_response: bool = False, process_response_as_bytes: bool = False, **request_kwargs, ): """Make a GET request to the given URL."""
-
def head(url, *, process_response: bool = False, **kwargs): """Make a head request."""
-
def post( url, *, update_headers_for_datatype: bool = True, process_response: bool = False, process_response_as_bytes: bool = False, **request_kwargs, ): """Make a POST request to the given URL with the given data."""
-
def headers_update(headers: Dict[str, str], new_header_key: str, new_header_value: Any, *, overwrite: bool = True): """."""
-
def put( url, *, update_headers_for_datatype: bool = True, process_response: bool = False, process_response_as_bytes: bool = False, **request_kwargs, ): """Make a PUT request to the given URL with the given data."""
-
def delete( url, *, process_response: bool = False, process_response_as_bytes: bool = False, **request_kwargs, ): """Make a DELETE request to the given URL with the given data."""
-
def url_hash(url, hash_type='sha256'): """Return the hash of the url."""
-
def urllib3_backoff_factor_executions(backoff_factor: float, number_of_requests: int): """Return the times (in seconds) of the first n requests with the given backoff_factor. See https://urllib3.readthedocs.io/en/latest/reference/index.html#urllib3.Retry under the "backoff_factor" argument."""
👋 If you want to get involved in this project, we have some short, helpful guides below:
If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.
This package was created with Cookiecutter and Floyd Hightower's Python project template.