- """Package-wide utilities."""
- from datetime import datetime
- import requests
- def raise_for_status(*, response: requests.Response) -> None:
- """
- Wrap requests method of same name to include response text in exception message.
- :param response: a response from any API call using the requests package
- """
- try:
-
- response.raise_for_status()
- except requests.HTTPError as err:
-
- raise requests.HTTPError(
- str(err) + f" with response body: {response.text}"
- ) from err
- def log_to_console(*, log: str, verbose: bool = True) -> None:
- """If verbose is true, then print log with timestamp prefix."""
- if verbose:
- print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {log}")