Module: host
This module provides objects used to retrieve hosts, host information and host
details from a copy of the Wait Wait Don't Tell Me! Stats database.
Host
-
class wwdtm.host.Host(connect_dict=None, database_connection=None)
Host information retrieval class.
Contains methods used to retrieve host information, including IDs,
names, slug strings and appearances.
- 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()
Retrieves host information for all hosts.
- Returns:
A list of dictionaries containing host ID, name, slug
string, gender and pronouns for each host
- Return type:
list[dict[str, int | str]]
-
retrieve_all_details()
Retrieves host information and appearances for all hosts.
- Returns:
A list of dictionaries containing host ID, name, slug
string, gender, pronouns, whether the host is also a guest,
host or scorekeeper, and a list of appearances with show
flags for each host
- Return type:
list[dict[str, Any]]
-
retrieve_all_ids()
Retrieves all host IDs, sorted by host name.
- Returns:
A list of host IDs as integers
- Return type:
list[int]
-
retrieve_all_slugs()
Retrieves all host slug strings, sorted by host name.
- Returns:
A list of host slug strings
- Return type:
list[str]
-
retrieve_by_id(host_id)
Retrieves host information.
- Parameters:
host_id (int) -- Host ID
- Returns:
A dictionary containing host ID, name, gender and slug string
- Return type:
dict[str, Any]
-
retrieve_by_slug(host_slug)
Retrieves host information.
- Parameters:
host_slug (str) -- Host slug string
- Returns:
A dictionary containing host ID, name, gender and slug
string
- Return type:
dict[str, Any]
-
retrieve_details_by_id(host_id)
Retrieves host information and appearances.
- Parameters:
host_id (int) -- Host ID
- Returns:
A dictionary containing host ID, name, slug string,
gender, pronouns, whether the host is also a guest, host or
scorekeeper, and a list of appearances with show flags
- Return type:
dict[str, Any]
-
retrieve_details_by_slug(host_slug)
Retrieves host information and appearances.
- Parameters:
host_slug (str) -- Host slug string
- Returns:
A dictionary containing host ID, name, slug string,
gender, pronouns, whether the host is also a guest, host or
scorekeeper, and a list of appearances with show flags
- Return type:
dict[str, Any]
-
retrieve_random()
Retrieves information for a random host.
- Returns:
A dictionary containing host ID, name, gender and slug
string
- Return type:
dict[str, Any]
-
retrieve_random_details()
Retrieves information and appearances for a random host.
- Returns:
A dictionary containing host ID, name, slug string,
gender, pronouns, whether the host is also a guest, host or
scorekeeper, and a list of appearances with show flags
- Return type:
dict[str, Any]
-
retrieve_random_id()
Retrieves an ID for a random host.
- Returns:
ID for a random host.
- Return type:
int
-
retrieve_random_slug()
Retrieves an slug string for a random host.
- Returns:
Slug string for a random host.
- Return type:
str
HostAppearances
-
class wwdtm.host.HostAppearances(connect_dict=None, database_connection=None)
Host appearance information retrieval class.
Contains methods used to retrieve host appearance 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_appearances_by_id(host_id)
Retrieves host appearance information.
- Parameters:
host_id (int) -- Host ID
- Returns:
A dictionary containing host appearances with
corresponding show dates and Best Of or Repeat show flags
- Return type:
dict[str, Any]
-
retrieve_appearances_by_slug(host_slug)
Retrieves host appearance information.
- Parameters:
host_slug (str) -- Host slug string
- Returns:
A dictionary containing host appearances with
corresponding show dates and Best Of or Repeat show flags
- Return type:
dict[str, Any]
HostUtility
-
class wwdtm.host.HostUtility(connect_dict=None, database_connection=None)
Host information and utilities class.
Contains methods used to convert between host ID and slug strings,
and to check if host IDs and slug strings exist.
- 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(host_id)
Converts a host ID to the corresponding host slug string.
- Parameters:
host_id (int) -- Host ID
- Returns:
Host slug string if a corresponding value is found.
Otherwise, None is returned
- Return type:
str | None
-
convert_slug_to_id(host_slug)
Converts a host slug string to the corresponding host ID.
- Parameters:
host_slug (str) -- Host slug string
- Returns:
Host ID as an integer if a corresponding value is
found. Otherwise, None is returned
- Return type:
int | None
-
id_exists(host_id)
Validates if a host ID exists.
- Parameters:
host_id (int) -- Host ID
- Returns:
True if the ID exists, otherwise False
- Return type:
bool
-
slug_exists(host_slug)
Validates if a host slug string exists.
- Parameters:
host_slug (str) -- Host slug string
- Returns:
True if the slug string exists, otherwise False
- Return type:
bool