Module: location
This module provides objects that are used to retrieve locations, location
information and location recordings from a copy of the Wait Wait Don't Tell Me!
Stats database.
Location
-
class wwdtm.location.Location(connect_dict=None, database_connection=None)
Location information retrieval class.
Contains methods used to retrieve location IDs, venue names and
locations, including city and state, and recording dates.
- Parameters:
connect_dict (dict[str, Any]) -- A dictionary containing database connection
settings as required by MySQL Connector/Python
database_connection (MySQLConnection | PooledMySQLConnection) -- MySQL database connection object
-
retrieve_all(sort_by_venue=False)
Retrieves location information for all locations.
- Parameters:
sort_by_venue (bool) -- A boolean to determine if the returned
list is sorted by venue first or by state and city first
- Returns:
A list of dictionaries containing location ID, venue
name, city, state and slug string
- Return type:
list[dict[str, int | str]]
-
retrieve_all_details(sort_by_venue=False)
Retrieves location information and recordings for all locations.
- Parameters:
sort_by_venue (bool) -- A boolean to determine if the returned
list is sorted by venue first or by state and city first
- Returns:
A list of dictionaries containing location ID, venue
name, city, state, slug string and a list of recordings
- Return type:
list[dict[str, Any]]
-
retrieve_all_ids(sort_by_venue=False)
Retrieves all location IDs.
- Parameters:
sort_by_venue (bool) -- A boolean to determine if the returned
list is sorted by venue first or by state and city first
- Returns:
A list of location IDs as integers
- Return type:
list[int]
-
retrieve_all_slugs(sort_by_venue=False)
Retrieves all location slug strings.
- Parameters:
sort_by_venue (bool) -- A boolean to determine if the returned
list is sorted by venue first or by state and city first
- Returns:
A list of location slug strings
- Return type:
list[str]
-
retrieve_by_id(location_id)
Retrieves location information.
- Parameters:
location_id (int) -- Location ID
- Returns:
A dictionary containing location ID, venue, city, state
and slug string
- Return type:
dict[str, int | str]
-
retrieve_by_slug(location_slug)
Retrieves location information.
- Parameters:
location_slug (str) -- Location slug string
- Returns:
A dictionary containing location ID, venue, city, state
and slug string
- Return type:
dict[str, int | str]
-
retrieve_details_by_id(location_id)
Retrieves location information and recordings.
- Parameters:
location_id (int) -- Location ID
- Returns:
A dictionary containing location ID, venue name, city,
state, slug string and a list of recordings
- Return type:
dict[str, Any]
-
retrieve_details_by_slug(location_slug)
Retrieves location information and recordings.
- Parameters:
location_slug (str) -- Location slug string
- Returns:
A dictionary containing location ID, venue name, city,
state, slug string and a list of recordings
- Return type:
dict[str, Any]
-
retrieve_postal_abbreviations()
Retrieves postal abbreviations, corresponding names and countries.
- Returns:
A dictionary containing postal abbreviation as keys
and corresponding name and country as values.
- Return type:
dict[str, dict[str, str]]
-
retrieve_postal_abbreviations_list()
Retrieves postal abbreviations, corresponding name and countries as a list.
- Returns:
A list of dictionaries, each containing postal abbreviation,
corresponding name and country.
- Return type:
list[dict[str, str]]
-
retrieve_postal_details_by_abbreviation(abbreviation)
Retrieves postal abbreviation information for a specific abbreviation.
- Parameters:
abbreviation (str) -- Postal Abbreviation
- Returns:
A dictionary containing postal abbreviation,
corresponding name, and country.
- Return type:
dict[str, str]
-
retrieve_random()
Retrieves information for a random location.
- Returns:
A dictionary containing location ID, venue, city, state
and slug string
- Return type:
dict[str, int | str]
-
retrieve_random_details()
Retrieves information and recordings for a random location.
- Returns:
A dictionary containing location ID, venue name, city,
state, slug string and a list of recordings
- Return type:
dict[str, Any]
-
retrieve_random_id()
Retrieves an ID for a random location.
- Returns:
ID for a random location.
- Return type:
int
-
retrieve_random_slug()
Retrieves a slug string for a random location.
- Returns:
Slug string for a random location.
- Return type:
str
LocationRecordings
-
class wwdtm.location.LocationRecordings(connect_dict=None, database_connection=None)
Location recording information retrieval class.
Contains methods used to retrieve recording information, including
show flags.
- Parameters:
connect_dict (dict[str, Any]) -- A dictionary containing database connection
settings as required by MySQL Connector/Python
database_connection (MySQLConnection | PooledMySQLConnection) -- MySQL database connection object
-
retrieve_recordings_by_id(location_id)
Retrieves location recording information.
Location recording information includes the corresponding show
dates and Best Of or Repeat show flags.
- Parameters:
location_id (int) -- Location ID
- Returns:
A dictionary containing location recording counts,
dates and show flags
- Return type:
dict[str, Any]
-
retrieve_recordings_by_slug(location_slug)
Retrieves location recording information.
Location recording information includes the corresponding show
dates and Best Of or Repeat show flags.
- Parameters:
location_slug (str) -- Location slug string
- Returns:
A dictionary containing location recording counts,
dates and show flags
- Return type:
dict[str, Any]
LocationUtility
-
class wwdtm.location.LocationUtility(connect_dict=None, database_connection=None)
Location information and utilities class.
This class contains supporting functions used to check whether
a location ID or slug string exists or to convert an ID to a slug
string, or vice versa.
- Parameters:
connect_dict (dict[str, Any]) -- A dictionary containing database connection
settings as required by MySQL Connector/Python
database_connection (MySQLConnection | PooledMySQLConnection) -- MySQL database connection object
-
convert_id_to_slug(location_id)
Converts a location ID to the corresponding location slug string.
- Parameters:
location_id (int) -- Location ID
- Returns:
Location slug string if a corresponding value is found.
Otherwise, None is returned
- Return type:
str | None
-
convert_slug_to_id(location_slug)
Converts a location slug string to the corresponding location ID.
- Parameters:
location_slug (str) -- Location slug string
- Returns:
Location ID if a corresponding value is found.
Otherwise, None is returned
- Return type:
int | None
-
id_exists(location_id)
Validates if a location ID exists.
- Parameters:
location_id (int) -- Location ID
- Returns:
True if the ID exists, otherwise False
- Return type:
bool
-
slug_exists(location_slug)
Validates if a location slug string exists.
- Parameters:
location_slug (str) -- Location slug string
- Returns:
True if the slug string exists, otherwise False
- Return type:
bool
-
static slugify_location(location_id=None, venue=None, city=None, state=None)
Generates a slug string using the location ID, venue, city and/or state.
- Parameters:
location_id (int) -- Location ID
venue (str) -- Location venue name
city (str) -- City where the location venue is located
state (str) -- State where the location venue is located
- Returns:
Location slug string
- Raises:
ValueError
- Return type:
str