mokkari package

Subpackages

Submodules

mokkari.exceptions module

Exceptions module.

This module provides the following classes:

  • ApiError

  • AuthenticationError

  • CacheError

exception mokkari.exceptions.ApiError(*args, **kwargs: dict[str, any])

Bases: Exception

Class for any api errors.

exception mokkari.exceptions.AuthenticationError(*args, **kwargs: dict[str, any])

Bases: Exception

Class for any authentication errors.

exception mokkari.exceptions.CacheError(*args, **kwargs: dict[str, any])

Bases: Exception

Class for any database cache errors.

mokkari.session module

Session module.

This module provides the following classes:

  • Session

class mokkari.session.Session(username: str, passwd: str, cache: SqliteCache | None = None, user_agent: str | None = None)

Bases: object

Session to request api endpoints.

Parameters:
  • username (str) – The username for authentication with metron.cloud

  • passwd (str) – The password used for authentication with metron.cloud

  • cache (SqliteCache, optional) – SqliteCache to use

  • optional (user_agent) – The user agent string for the application using Mokkari.

arc(_id: int) Arc

Request data for a story arc based on its _id.

Parameters:

_id (int) – The story arc id.

Returns:

A Arc object.

Raises:

ApiError – If there is a problem with the API request.

arc_issues_list(_id: int) list[BaseIssue]

Request a list of issues for a story arc.

Parameters:

_id (int) – The arc id.

Returns:

A list of Issue objects.

arcs_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of story arcs.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A ArcsList object.

character(_id: int) Character

Request data for a character based on its _id.

Parameters:

_id (int) – The character id.

Returns:

A Character object.

Raises:

ApiError – If there is a problem with the API request.

character_issues_list(_id: int) list[BaseIssue]

Request a list of issues that a character appears in.

New in version 2.2.0.

Parameters:

_id (int) – The character id.

Returns:

A list of Issue objects.

characters_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of characters.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A CharactersList object.

creator(_id: int) Creator

Request data for a creator based on its _id.

Parameters:

_id (int) – The creator id.

Returns:

A Creator object.

Raises:

ApiError – If there is a problem with the API request.

creators_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of creators.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A CreatorsList object.

issue(_id: int) Issue

Request data for an issue based on it’s _id.

Parameters:

_id (int) – The issue id.

Returns:

A Issue object.

Raises:

ApiError – If there is a problem with the API request.

issues_list(params: dict[str, str | int] | None = None) list[BaseIssue]

Request a list of issues.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A IssuesList object.

publisher(_id: int) Publisher

Request data for a publisher based on its _id.

Parameters:

_id (int) – The publisher id.

Returns:

A Publisher object.

Raises:

ApiError – If there is a problem with the API request.

publishers_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of publishers.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A PublishersList object.

role_list(params: dict[str, str | int] | None = None) list[GenericItem]

Request a list of creator roles.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A RoleList object.

series(_id: int) Series

Request data for a series based on its _id.

Parameters:

_id (int) – The series id.

Returns:

A Series object.

Raises:

ApiError – If there is a problem with the API request.

series_list(params: dict[str, str | int] | None = None) list[BaseSeries]

Request a list of series.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A SeriesList object.

series_type_list(params: dict[str, str | int] | None = None) list[GenericItem]

Request a list of series types.

New in version 2.2.2:

  • Add series_type_list method

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A SeriesTypeList object.

team(_id: int) Team

Request data for a team based on its _id.

Parameters:

_id (int) – The team id.

Returns:

A Team object.

Raises:

ApiError – If there is a problem with the API request.

team_issues_list(_id: int) list[BaseIssue]

Request a list of issues that a team appears in.

New in version 2.2.0.

Parameters:

_id (int) – The team id.

Returns:

A list of Issue objects.

teams_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of teams.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A TeamsList object.

universe(_id: int) Universe

Request data for a universe based on its _id.

Parameters:

_id (int) – The universe id.

Returns:

A Universe object.

Raises:

ApiError – If there is a problem with the API request.

universes_list(params: dict[str, str | int] | None = None) list[BaseResource]

Request a list of universes.

Parameters:

params (dict, optional) – Parameters to add to the request.

Returns:

A list of BaseUniverse objects.

mokkari.sqlite_cache module

SQLite Cache module.

This module provides the following classes:

  • SqliteCache

class mokkari.sqlite_cache.SqliteCache(db_name: str = 'mokkari_cache.db', expire: int | None = None)

Bases: object

The SqliteCache object to cache search results from Metron.

Parameters:
  • db_name (str) – Path and database name to use.

  • expire (int, optional) – The number of days to keep the cache results

  • expire. (before they) –

cleanup() None

Remove any expired data from the cache database.

get(key: str) Any | None

Retrieve data from the cache database.

Parameters:

key (str) – value to search for.

store(key: str, value: str) None

Save data to the cache database.

Parameters:
  • key (str) – Item id.

  • value (str) – data to save.

Module contents

Project entry file.

mokkari.api(username: str | None = None, passwd: str | None = None, cache: SqliteCache = None, user_agent: str | None = None) Session

Entry function the sets login credentials for metron.cloud.

Parameters:
  • username (str) – The username used for metron.cloud.

  • passwd (str) – The password used for metron.cloud.

  • cache (SqliteCache) – SqliteCache to use

  • user_agent (str) – The user agent string for the application using Mokkari.

  • Bar/1.0'. (For example 'Foo) –

Returns:

A Session object

Raises:

AuthenticationError – If Metron returns with an invalid API credentials response.

New in version 2.5.0:

  • Added user_agent argument.