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.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
ServiceError – If there is an issue with validating the response.
- character_list(params: Optional[Dict[str, Union[str, int]]] = None) List[Character]
Request data for a list of Characters.
- Parameters
params – Parameters to add to the request.
- Returns
A list of CharacterResult objects.
- Raises
ServiceError – If there is an issue with validating the response.
- 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
ServiceError – If there is an issue with validating the response.
- creator_list(params: Optional[Dict[str, Union[str, int]]] = None) List[Creator]
Request data for a list of Creators.
- Parameters
params – Parameters to add to the request.
- Returns
A list of CreatorResult objects.
- Raises
ServiceError – If there is an issue with validating the response.
- 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
ServiceError – If there is an issue with validating the response.
- issue_list(params: Optional[Dict[str, Union[str, int]]] = None) List[Issue]
Request data for a list of Issues.
- Parameters
params – Parameters to add to the request.
- Returns
A list of IssueResult objects.
- Raises
ServiceError – If there is an issue with validating the response.
- 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
ServiceError – If there is an issue with validating the response.
- publisher_list(params: Optional[Dict[str, Any]] = None) List[Publisher]
Request data for a list of Publishers.
- Parameters
params – Parameters to add to the request.
- Returns
A list of Publisher objects.
- Raises
ServiceError – If there is an issue with validating the response.
- search(resource: ComicvineResource, query: str) Union[List[Publisher], List[Volume], List[Issue], List[StoryArc], List[Creator], List[Character]]
Request a list of search results filtered by provided resource.
- Parameters
resource – Filter which type of resource to return.
query – Search query string.
- Returns
A list of results, mapped to the given resource.
- Raises
ServiceError – If there is an issue with validating the response.
- 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
ServiceError – If there is an issue with validating the response.
- story_arc_list(params: Optional[Dict[str, Union[str, int]]] = None) List[StoryArc]
Request data for a list of Story Arcs.
- Parameters
params – Parameters to add to the request.
- Returns
A list of StoryArcResult objects.
- Raises
ServiceError – If there is an issue with validating the response.
- 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
ServiceError – If there is an issue with validating the response.
- volume_list(params: Optional[Dict[str, Union[str, int]]] = None) List[Volume]
Request data for a list of Volumes.
- Parameters
params – Parameters to add to the request.
- Returns
A list of VolumeResult objects.
- Raises
ServiceError – If there is an issue with validating the response.
- API_URL = 'https://comicvine.gamespot.com/api'
- class simyan.comicvine.ComicvineResource(value)
Bases:
Enum
Enum class for Comicvine Resources.
- CHARACTER = (4005, 'character', typing.List[simyan.schemas.character.Character])
- CREATOR = (4040, 'person', typing.List[simyan.schemas.creator.Creator])
- ISSUE = (4000, 'issue', typing.List[simyan.schemas.issue.Issue])
- PUBLISHER = (4010, 'publisher', typing.List[simyan.schemas.publisher.Publisher])
- STORY_ARC = (4045, 'story_arc', typing.List[simyan.schemas.story_arc.StoryArc])
- VOLUME = (4050, 'volume', typing.List[simyan.schemas.volume.Volume])
- property resource_id: int
Start of id used by comicvine to create unique ids.
- property search_resource: str
Resource string for filtering searches.
- property search_response: Type[T]
Response type for resource when using a search endpoint.
simyan.exceptions module
The Exceptions module.
This module provides the following classes:
ServiceError
AuthenticationError
CacheError
- exception simyan.exceptions.AuthenticationError
Bases:
ServiceError
Class for any authentication errors.
- exception simyan.exceptions.CacheError
Bases:
ServiceError
Class for any database cache errors.
- exception simyan.exceptions.ServiceError
Bases:
Exception
Class for any API errors.
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