boilerplate

class API[source]

Bases: object

__init__(sync: bool = False)[source]
logger: logging.Logger
api: novelai_api.NovelAI_API.NovelAIAPI
property encryption_key
error_handler(func_ext: Callable[[Any, Any], Awaitable[Any]] | None = None, *, attempts: int = 5, wait: int = 5)[source]

Decorator to add error handling to the decorated function The function must accept an API object as first arguments

Parameters:
  • func_ext – Substitute for func if the decorator is run without argument. Do not provide it directly

  • attempts – Number of attempts to do before raising the error

  • wait – Time (in seconds) to wait after each call

class JSONEncoder[source]

Bases: json.encoder.JSONEncoder

Extended JSON encoder to support bytes

default(o: Any) Any[source]
dumps(e: Any) str[source]

Shortcut to a configuration of json.dumps for consistency

api_handle()[source]

API handle for an Async Test. Use it as a pytest fixture

api_handle_sync()[source]

API handle for a Sync Test. Use it as a pytest fixture