Skip to content

CardSetCollection

Bases: UserDict

Represents a collection of card sets, stored by identifier.

Note

This class inherits collections.UserDict, and thus supports any common dict methods.

Attributes:

Name Type Description
data dict[str, CardSet]

The mapping of str identifiers to CardSet objects.

editions()

Returns the set of all card set editions within this card set collection.

Returns:

Type Description
list[str]

A unique list of all card set editions within the set collection.

from_csv(csvstr, delimiter='\t') staticmethod

Creates a new card set collection given a CSV string representation.

Parameters:

Name Type Description Default
csvstr str

The CSV string representation to parse.

required
delimiter str

An optional csv.DictReader delimiter to use when parsing.

'\t'

Returns:

Type Description
CardSetCollection

A new CardSetCollection from the parsed data.

from_json(jsonstr) staticmethod

Creates a new card set collection given a JSON string representation.

Parameters:

Name Type Description Default
jsonstr str

The JSON string representation to parse.

required

Returns:

Type Description
CardSetCollection

A new CardSetCollection from the parsed data.

get_release_date(card)

Returns the release date for the specified card by looking up its card set(s).

Note

The earliest date will be returned for cards released more than once. This method returns None if no release date is found.

Parameters:

Name Type Description Default
card Card

The card to obtain the release date of.

required

Returns:

Type Description
Optional[datetime.date]

The release date of the specified card, or None if not found.

identifiers()

Returns the set of all card set identifiers within this card set collection.

Returns:

Type Description
list[str]

The unique list of all card set identifiers within the collection.

load(file_path, set_catalog=False) staticmethod

Loads a card set collection from the specified .json or .csv file.

Note

If set_catalog is set to True, then a cop of the card set collection will be set as the default card_set.CATALOG.

Parameters:

Name Type Description Default
file_path str

The file path from which to load the card set collection.

required
set_catalog bool

Whether to set the loaded data as the default card set catalog.

False

Returns:

Type Description
CardSetCollection

A new CardSetCollection from the loaded data.

names()

Returns the set of all card set names within this card set collection.

Returns:

Type Description
list[str]

A unique list of all card set names within the collection.

release_dates()

Returns the set of all card set release dates within this card set collection.

Returns:

Type Description
list[datetime.date]

A unique list of all card set release dates within the collection.

save(file_path)

Saves the card set collection to the specified file path.

Parameters:

Name Type Description Default
file_path str

The file path to save to.

required

to_dataframe()

Converts the list of card sets into a pandas DataFrame.

Returns:

Type Description
DataFrame

A pandas DataFrame object representing the list of card sets.

to_json()

Computes the JSON string representation of this collection of card sets.

Returns:

Type Description
str

The JSON string representation of the collection.