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)

This class contains functions used to retrieve host 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()

Returns a list of dictionary objects containing host ID, name and slug string for all hosts.

Return type:

List[Dict[str, Any]]

Returns:

List of all hosts and their corresponding information. If hosts could not be retrieved, an empty list is returned.

retrieve_all_details()

Returns a list of dictionary objects containing host ID, name, slug string and appearance information for all hosts.

Return type:

List[Dict[str, Any]]

Returns:

List of all hosts and their corresponding information and appearances. If hosts could not be retrieved, an empty list is returned.

retrieve_all_ids()

Returns a list of all host IDs from the database, sorted by host name.

Return type:

List[int]

Returns:

List of all host IDs. If host IDs could not be retrieved, an empty list is returned.

retrieve_all_slugs()

Returns a list of all host slug strings from the database, sorted by host name.

Return type:

List[str]

Returns:

List of all host slug strings. If host slug strings could not be retrieved, an empty list is returned.

retrieve_by_id(host_id)

Returns a dictionary object containing host ID, name and slug string for the requested host ID.

Parameters:

host_id (int) – Host ID

Return type:

Dict[str, Any]

Returns:

Dictionary containing host information. If host information could not be retrieved, an empty dictionary is returned.

retrieve_by_slug(host_slug)

Returns a dictionary object containing host ID, name and slug string for the requested host slug string.

Parameters:

host_slug (str) – Host slug string

Return type:

Dict[str, Any]

Returns:

Dictionary containing host information. If host information could be retrieved, an empty dictionary is returned.

retrieve_details_by_id(host_id)

Returns a dictionary object containing host ID, name, slug string and appearance information for the requested host ID.

Parameters:

host_id (int) – Host ID

Return type:

Dict[str, Any]

Returns:

Dictionary containing host information and their appearances. If host information could be retrieved, an empty dictionary is returned.

retrieve_details_by_slug(host_slug)

Returns a dictionary object containing host ID, name, slug string and appearance information for the requested host slug string.

Parameters:

host_slug (str) – Host slug string

Return type:

Dict[str, Any]

Returns:

Dictionary containing host information and their appearances. If host information could be retrieved, an empty dictionary is returned.

HostAppearances

class wwdtm.host.HostAppearances(connect_dict=None, database_connection=None)

This class contains functions that retrieve host appearance 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_appearances_by_id(host_id)

Returns a list of dictionary objects containing appearance information for the requested host ID.

Parameters:

host_id (int) – Host ID

Return type:

Dict[str, Any]

Returns:

Dictionary containing appearance counts and list of appearances for a host. If host appearances could not be retrieved, an empty dictionary is returned.

retrieve_appearances_by_slug(host_slug)

Returns a list of dictionary objects containing appearance information for the requested host ID.

Parameters:

host_slug (str) – Host slug string

Return type:

Dict[str, Any]

Returns:

Dictionary containing appearance counts and list of appearances for a host. If host appearances could not be retrieved, an empty dictionary is returned.

HostUtility

class wwdtm.host.HostUtility(connect_dict=None, database_connection=None)

This class contains supporting functions used to check whether a host 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(host_id)

Converts a host’s ID to the matching host slug string value.

Parameters:

host_id (int) – Host ID

Return type:

Optional[str]

Returns:

Host slug string, if a match is found

convert_slug_to_id(host_slug)

Converts a host’s slug string to the matching host ID value.

Parameters:

host_slug (str) – Host slug string

Return type:

Optional[int]

Returns:

Host ID, if a match is found

id_exists(host_id)

Checks to see if a host ID exists.

Parameters:

host_id (int) – Host ID

Return type:

bool

Returns:

True or False, based on whether the host ID exists

slug_exists(host_slug)

Checks to see if a host slug string exists.

Parameters:

host_slug (str) – Host slug string

Return type:

bool

Returns:

True or False, based on whether the host slug string exists