scryfall_cache package¶
Submodules¶
scryfall_cache.scryfall_cache module¶
Classes for main Scryfall cache objects.
-
class
scryfall_cache.scryfall_cache.ScryfallCache(application=None, version=None, bulk_update_period=7257600, sql_debug=False)[source]¶ Bases:
objectMain cache object.
-
BULK_DATA_LIST= 'default_cards'¶
-
DATABASE_FILENAME= 'scryfallcache.sqlite3'¶
-
get_cache_directory()[source]¶ Get the top level cache directory that this instance is using.
Useful for other libraries if they want to store data in ScryfallCache’s cache folder.
- Returns:
- str: the cache directory path.
-
get_card(name=None, scryfall_id=None, mtgo_id=None)[source]¶ Attempt to get a ScryfallCard object for any given identifiers.
- Args:
- name (str): The name of the card if known. scryfall_id (str): The Scryfall ID of the card if known. mtgo_id (int): The MTGO ID of the card if known.
- Raises:
- ScryfallCacheException: if no identifiers are given.
- Returns:
- ScryfallCard if ID found, else None.
-
get_local_image_path(card, art_format)[source]¶ Retrieve the local image path for a given image.
If necessary, download the image into place before returning.
- Args:
card (ScryfallCard): ScryfallCard object returned from get_card(). art_format (str): One of the art formats to download. See
https://scryfall.com/docs/api/images for more detail.- Raises:
- ScryfallCacheException: on failure
- Returns:
- str: the file path
-
-
exception
scryfall_cache.scryfall_cache.ScryfallCacheException[source]¶ Bases:
exceptions.ExceptionException raised by ScryfallCache.
-
class
scryfall_cache.scryfall_cache.ScryfallCard(cache, card_dict)[source]¶ Bases:
objectWrapper object for a Scryfall card data dictionary.
-
get_dict()[source]¶ Return the card data dictionary for this card.
- Returns:
- dict: The card data dictionary for this card.
-
get_id()[source]¶ Return the Scryfall ID for this card.
- Returns:
- str: The Scryfall ID for this card.
-
get_image_path(art_format)[source]¶ Get or download the chosen art format for this card.
- Args:
- art_format (str): One of the art formats to download. See
- https://scryfall.com/docs/api/images for more detail.
- Returns:
- str: Path to local file.
-
-
scryfall_cache.scryfall_cache.define_entities(db)[source]¶ Define entities on a database object.
- Args:
- db (orm.Database): Database object to define entities on.
-
scryfall_cache.scryfall_cache.open_database(database_path, create_db=True, sql_debug=False)[source]¶ Create a connection to an sqlite database.
- Args:
- database_path (str): Path to the sqlite database. create_db (bool): Whether to create the database if it doesn’t exist. sql_debug (bool): Whether to enable SQL debugging
- Returns:
- Database object
Module contents¶
Top-level package for scryfall-cache.
-
class
scryfall_cache.ScryfallCache(application=None, version=None, bulk_update_period=7257600, sql_debug=False)[source]¶ Bases:
objectMain cache object.
-
BULK_DATA_LIST= 'default_cards'¶
-
DATABASE_FILENAME= 'scryfallcache.sqlite3'¶
-
get_cache_directory()[source]¶ Get the top level cache directory that this instance is using.
Useful for other libraries if they want to store data in ScryfallCache’s cache folder.
- Returns:
- str: the cache directory path.
-
get_card(name=None, scryfall_id=None, mtgo_id=None)[source]¶ Attempt to get a ScryfallCard object for any given identifiers.
- Args:
- name (str): The name of the card if known. scryfall_id (str): The Scryfall ID of the card if known. mtgo_id (int): The MTGO ID of the card if known.
- Raises:
- ScryfallCacheException: if no identifiers are given.
- Returns:
- ScryfallCard if ID found, else None.
-
get_local_image_path(card, art_format)[source]¶ Retrieve the local image path for a given image.
If necessary, download the image into place before returning.
- Args:
card (ScryfallCard): ScryfallCard object returned from get_card(). art_format (str): One of the art formats to download. See
https://scryfall.com/docs/api/images for more detail.- Raises:
- ScryfallCacheException: on failure
- Returns:
- str: the file path
-