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)
This class contains functions used to retrieve location data
from a copy of the Wait Wait Stats database.
- Parameters:
connect_dict (Optional
[Dict
[str
, Any
]]) – Dictionary containing database connection
settings as required by mysql.connector.connect
database_connection (Optional
[connect
]) – mysql.connector.connect database
connection
-
retrieve_all(sort_by_venue=False)
Returns a list of dictionary objects containing location ID,
city, state, venue and slug string for all locations.
- Parameters:
sort_by_venue (bool
) – Sets whether to sort by venue first, or
by state and city first
- Return type:
List
[Dict
[str
, Any
]]
- Returns:
List of all locations and their corresponding
information. If locations could not be retrieved, an empty
list is returned.
-
retrieve_all_details(sort_by_venue=False)
Returns a list of dictionary objects containing location ID,
city, state, venue, slug string and recording information for
all locations.
- Parameters:
sort_by_venue (bool
) – Sets whether to sort by venue first, or
by state and city first
- Return type:
List
[Dict
[str
, Any
]]
- Returns:
List of all locations and their corresponding
information and recordings. If locations could not be
retrieved, an empty list is returned.
-
retrieve_all_ids(sort_by_venue=False)
Returns a list of all locations IDs from the database.
- Parameters:
sort_by_venue (bool
) – Sets whether to sort by venue first, or
by state and city first
- Return type:
List
[int
]
- Returns:
List of all location IDs. If location IDs could not be
retrieved, an empty list is returned.
-
retrieve_all_slugs(sort_by_venue=False)
Returns a list of all location slug strings from the
database.
- Parameters:
sort_by_venue (bool
) – Sets whether to sort by venue first, or
by state and city first
- Return type:
List
[str
]
- Returns:
List of all location slug strings. If location slug
strings could not be retrieved, an empty list is returned.
-
retrieve_by_id(location_id)
Returns a dictionary object containing location ID, venue,
city, state and slug string for the requested location ID.
- Parameters:
location_id (int
) – Location ID
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing location information. If
location information could not be retrieved, an empty
dictionary is returned.
-
retrieve_by_slug(location_slug)
Returns a dictionary object containing location ID, venue,
city, state and slug string for the requested location ID.
- Parameters:
location_slug (str
) – Location slug string
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing location information. If
location information could not be retrieved, an empty
dictionary is returned.
-
retrieve_details_by_id(location_id)
Returns a dictionary object containing location ID, venue,
city, state, slug string and a list of recordings for the
requested location ID.
- Parameters:
location_id (int
) – Location ID
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing location information and their
recordings. If location information could not be retrieved,
an empty dictionary is returned.
-
retrieve_details_by_slug(location_slug)
Returns a dictionary object containing location ID, venue,
city, state, slug string and a list of recordings for the
requested location slug string.
- Parameters:
location_slug (str
) – Location slug string
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing location information and their
recordings. If location information could not be retrieved,
an empty dictionary is returned.
LocationRecordings
-
class wwdtm.location.LocationRecordings(connect_dict=None, database_connection=None)
This class contains functions that retrieve location recordings
information from a copy of the Wait Wait Stats database.
- Parameters:
connect_dict (Optional
[Dict
[str
, Any
]]) – Dictionary containing database connection
settings as required by mysql.connector.connect
database_connection (Optional
[connect
]) – mysql.connector.connect database
connection
-
retrieve_recordings_by_id(location_id)
Returns a list of dictionary objects containing recording
information for the requested location ID.
- Parameters:
location_id (int
) – Location ID
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing recording counts and a list of
appearances for a location. If location recordings could
not be retrieved, an empty dictionary is returned.
-
retrieve_recordings_by_slug(location_slug)
Returns a list of dictionary objects containing recording
information for the requested location slug string.
- Parameters:
location_slug (str
) – Location slug string
- Return type:
Dict
[str
, Any
]
- Returns:
Dictionary containing recording counts and a list of
appearances for a location. If location recordings could
not be retrieved, an empty dictionary is returned.
LocationUtility
-
class wwdtm.location.LocationUtility(connect_dict=None, database_connection=None)
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 (Optional
[Dict
[str
, Any
]]) – Dictionary containing database connection
settings as required by mysql.connector.connect
database_connection (Optional
[connect
]) – mysql.connector.connect database
connection
-
convert_id_to_slug(location_id)
Converts a location’s ID to the matching location slug
string value.
- Parameters:
location_id (int
) – Location ID
- Return type:
Optional
[str
]
- Returns:
Location slug string, if a match is found
-
convert_slug_to_id(location_slug)
Converts a location’s slug string to the matching location
ID value.
- Parameters:
location_slug (str
) – Location slug string
- Return type:
Optional
[int
]
- Returns:
Location ID, if a match is found
-
id_exists(location_id)
Checks to see if a location ID exists.
- Parameters:
location_id (int
) – Location ID
- Return type:
bool
- Returns:
True or False, based on whether the location ID exists
-
slug_exists(location_slug)
Checks to see if a location slug string exists.
- Parameters:
location_slug (str
) – Location slug string
- Return type:
bool
- Returns:
True or False, based on whether the location slug
string exists
-
static slugify_location(location_id=None, venue=None, city=None, state=None)
Generates a slug string based on the location’s venue name,
city, state and/or location ID.
- Parameters:
-
- Return type:
str
- Returns:
Location slug string
- Raises:
ValueError