simyan package

Subpackages

Module contents

simyan package entry file.

simyan.get_cache_root() Path

Create and return the path to the cache for simyan.

Returns

The path to the simyan cache

Submodules

simyan.exceptions module

The Exceptions module.

This module provides the following classes:

  • APIError

  • AuthenticationError

  • CacheError

exception simyan.exceptions.APIError

Bases: Exception

Class for any API errors.

exception simyan.exceptions.AuthenticationError

Bases: APIError

Class for any authentication errors.

exception simyan.exceptions.CacheError

Bases: APIError

Class for any database cache errors.

simyan.comicvine module

The Comicvine module.

This module provides the following classes:

  • ComicvineResource

  • Comicvine

class simyan.comicvine.Comicvine(api_key: str, timeout: int = 30, cache: Optional[SQLiteCache] = None)

Bases: object

Comicvine to request Comicvine API endpoints.

Parameters
  • api_key – User’s API key to access the Comicvine API.

  • timeout – Set how long requests will wait for a response (in seconds).

  • cache – SQLiteCache to use if set.

Variables
  • headers (Dict[str, str]) – Header used when requesting from Comicvine API.

  • api_key (str) – User’s API key to access the Comicvine API.

  • timeout (int) – How long requests will wait for a response (in seconds).

  • cache (Optional[SQLiteCache]) – SQLiteCache to use if set.

character(character_id: int) Character

Request data for a Character based on its id.

Parameters

character_id – The Character id.

Returns

A Character object

Raises

APIError – If there is an issue with mapping the response to the Character object.

character_list(params: Optional[Dict[str, Union[str, int]]] = None) List[CharacterResult]

Request data for a list of Characters.

Parameters

params – Parameters to add to the request.

Returns

A list of CharacterResult objects.

Raises

APIError – If there is an issue with mapping the response to the CharacterList object.

creator(creator_id: int) Creator

Request data for a Creator based on its id.

Parameters

creator_id – The Creator id.

Returns

A Creator object

Raises

APIError – If there is an issue with mapping the response to the Creator object.

creator_list(params: Optional[Dict[str, Union[str, int]]] = None) List[CreatorResult]

Request data for a list of Creators.

Parameters

params – Parameters to add to the request.

Returns

A list of CreatorResult objects.

Raises

APIError – If there is an issue with mapping the response to the CreatorList object.

issue(issue_id: int) Issue

Request data for an Issue based on its id.

Parameters

issue_id – The Issue id.

Returns

A Issue object

Raises

APIError – If there is an issue with mapping the response to the Issue object.

issue_list(params: Optional[Dict[str, Union[str, int]]] = None) List[IssueResult]

Request data for a list of Issues.

Parameters

params – Parameters to add to the request.

Returns

A list of IssueResult objects.

Raises

APIError – If there is an issue with mapping the response to the IssueList object.

publisher(publisher_id: int) Publisher

Request data for a Publisher based on its id.

Parameters

publisher_id – The Publisher id.

Returns

A Publisher object

Raises

APIError – If there is an issue with mapping the response to the Publisher object.

publisher_list(params: Optional[Dict[str, Any]] = None) List[PublisherResult]

Request data for a list of Publishers.

Parameters

params – Parameters to add to the request.

Returns

A list of PublisherResult objects.

Raises

APIError – If there is an issue with mapping the response to the PublisherList object.

story_arc(story_arc_id: int) StoryArc

Request data for a Story Arc based on its id.

Parameters

story_arc_id – The StoryArc id.

Returns

A StoryArc object

Raises

APIError – If there is an issue with mapping the response to the StoryArc object.

story_arc_list(params: Optional[Dict[str, Union[str, int]]] = None) List[StoryArcResult]

Request data for a list of Story Arcs.

Parameters

params – Parameters to add to the request.

Returns

A list of StoryArcResult objects.

Raises

APIError – If there is an issue with mapping the response to the StoryArcList object.

volume(volume_id: int) Volume

Request data for a Volume based on its id.

Parameters

volume_id – The Volume id.

Returns

A Volume object

Raises

APIError – If there is an issue with mapping the response to the Volume object.

volume_list(params: Optional[Dict[str, Union[str, int]]] = None) List[VolumeResult]

Request data for a list of Volumes.

Parameters

params – Parameters to add to the request.

Returns

A list of VolumeResult objects.

Raises

APIError – If there is an issue with mapping the response to the VolumeList object.

API_URL = 'https://comicvine.gamespot.com/api'
class simyan.comicvine.ComicvineResource(value)

Bases: Enum

Class for Comicvine Resource ids.

CHARACTER = 4005
CREATOR = 4040
ISSUE = 4000
PUBLISHER = 4010
STORY_ARC = 4045
VOLUME = 4050

simyan.sqlite_cache module

The SQLiteCache module.

This module provides the following classes:

  • SQLiteCache

class simyan.sqlite_cache.SQLiteCache(path: str = PosixPath('/home/docs/.cache/simyan/cache.sqlite'), expiry: Optional[int] = 14)

Bases: object

The SQLiteCache object to cache search results from ComicVine.

Parameters
  • path – Path to database.

  • expiry – How long to keep cache results.

Variables
  • expiry (Optional[int]) – How long to keep cache results.

  • con (sqlite3.Connection) – Database connection

  • cur (sqlite3.Cursor) – Database cursor

delete()

Remove all expired data from the cache database.

get(key: str) Optional[Dict[str, Any]]

Retrieve data from the cache database.

Parameters

key – Search string

Returns

None or select results.

insert(query: str, response: str)

Insert data into the cache database.

Parameters
  • query – Search string

  • response – Data to save

select(query: str) Dict[str, Any]

Retrieve data from the cache database.

Parameters

query – Search string

Returns

Empty dict or select results.

store(key: str, value: str)

Insert data into the cache database.

Parameters
  • key – Search string

  • value – Data to save