stockstert.utils package

Submodules

stockstert.utils.anilist module

class stockstert.utils.anilist.GraphQlClient(api_url: str)

Bases: object

A simple API wrapper for GraphQL APIs

__init__(api_url: str)

Initializes the GraphQL API wrapper :param api_url: The API endpoint URL

query(query_string: str, variables: Optional[Dict[str, Any]]) → Optional[Dict[str, Any]]

Executes a GraphQL query :param query_string: The query string to use :param variables: The variables to send :return: The response JSON, or None if an error occurred.

stockstert.utils.anilist.guess_latest_manga_chapter(anilist_id: int) → Optional[int]

Guesses the latest chapter number based on anilist user activity :param anilist_id: The anilist ID to check :return: The latest chapter number

stockstert.utils.anilist.load_anilist(username: str, media_type: str, list_name: Optional[str] = None) → List[Dict[str, Any]]

Loads the anilist for a user :param username: The username :param media_type: The media type, either MANGA or ANIME :param list_name: Optionalyy restrict to a specific list :return: The anilist

stockstert.utils.decorators module

stockstert.utils.decorators.api(func: Callable) → Callable

Decorator that handles common API patterns and ensures that the JSON response will always follow a certain pattern :param func: The function to wrap :return: The wrapper function

stockstert.utils.decorators.api_login_required(func: Callable) → Callable

Decorator to make unauthorized API calls respond with JSON properly :param func: The function to wrap :return: The wrapped function

stockstert.utils.env module

stockstert.utils.env.load_secrets(secrets_file: str)

Loads a JSON file filled with configuration details and secrets into os.environ :param secrets_file: The file to load :return: None

stockstert.utils.env.resolve_env_variable(env_key: str, _type: type = <class 'str'>, default: object = None) → object

Resolves an environment key. A non-existant environment key will lead to a KeyError unless the app is in testing mode, in which case database-related variables won’t cause a KeyError. KeyErrors can also be provided using the ‘default’ argument :param env_key: The environment key to resolve :param _type: The type of the environment variable :param default: An optional default value :return: The resolved environment variable.

None if the app is in testing mode and the variable is db-related

Module contents