Skip to content

Venue

Venue Class

Represents a venue with associated details, such as name, address, and type of surface.

Attributes:

Name Type Description
venue_json dict

The raw JSON data representing the venue.

venue_id str

The unique ID of the venue.

name str

The full name of the venue.

address_json dict

The address details of the venue.

grass bool

Flag indicating if the venue has a grass surface.

indoor bool

Flag indicating if the venue is indoors.

images list

A list of image URLs related to the venue.

Methods:

Name Description
__repr__

Returns a string representation of the Venue instance.

to_dict

Converts the venue data to a dictionary format.

Source code in pyespn/classes/venue.py
@validate_json("venue_json")
class Venue:
    """
    Represents a venue with associated details, such as name, address, and type of surface.

    Attributes:
        venue_json (dict): The raw JSON data representing the venue.
        venue_id (str): The unique ID of the venue.
        name (str): The full name of the venue.
        address_json (dict): The address details of the venue.
        grass (bool): Flag indicating if the venue has a grass surface.
        indoor (bool): Flag indicating if the venue is indoors.
        images (list): A list of image URLs related to the venue.

    Methods:
        __repr__(): Returns a string representation of the Venue instance.
        to_dict(): Converts the venue data to a dictionary format.
    """

    def __init__(self, venue_json, espn_instance):
        """
        Initializes a Venue instance using the provided venue JSON data.

        Args:
            venue_json (dict): The raw JSON data representing the venue.
            espn_instance (object): The ESPN instance used for making API calls.
        """

        self.venue_json = venue_json
        self._espn_instance = espn_instance
        self.venue_id = self.venue_json.get('id')
        self.name = self.venue_json.get('fullName')
        self.address_json = self.venue_json.get('address')
        self.grass = self.venue_json.get('grass')
        self.indoor = self.venue_json.get('indoor')
        self._images = [Image(image_json=image, espn_instance=self.espn_instance) for image in self.venue_json.get('images', [])]

    @property
    def espn_instance(self):
        """
            PYESPN: the espn client instance associated with the class
        """
        return self._espn_instance

    @property
    def images(self):
        """
            list[Image]: a list of images for the venue
        """
        return self._images

    def __repr__(self) -> str:
        """
        Returns a string representation of the Venue instance.

        Returns:
            str: A formatted string with the venues name.
        """
        return f"<Venue | {self.name}>"

    def to_dict(self) -> dict:
        """
        Converts the venue data to a dictionary format.

        Returns:
            dict: The raw JSON data representing the venue.
        """
        return self.venue_json

espn_instance property

PYESPN: the espn client instance associated with the class

images property

list[Image]: a list of images for the venue

__init__(venue_json, espn_instance)

Initializes a Venue instance using the provided venue JSON data.

Parameters:

Name Type Description Default
venue_json dict

The raw JSON data representing the venue.

required
espn_instance object

The ESPN instance used for making API calls.

required
Source code in pyespn/classes/venue.py
def __init__(self, venue_json, espn_instance):
    """
    Initializes a Venue instance using the provided venue JSON data.

    Args:
        venue_json (dict): The raw JSON data representing the venue.
        espn_instance (object): The ESPN instance used for making API calls.
    """

    self.venue_json = venue_json
    self._espn_instance = espn_instance
    self.venue_id = self.venue_json.get('id')
    self.name = self.venue_json.get('fullName')
    self.address_json = self.venue_json.get('address')
    self.grass = self.venue_json.get('grass')
    self.indoor = self.venue_json.get('indoor')
    self._images = [Image(image_json=image, espn_instance=self.espn_instance) for image in self.venue_json.get('images', [])]

__repr__()

Returns a string representation of the Venue instance.

Returns:

Name Type Description
str str

A formatted string with the venues name.

Source code in pyespn/classes/venue.py
def __repr__(self) -> str:
    """
    Returns a string representation of the Venue instance.

    Returns:
        str: A formatted string with the venues name.
    """
    return f"<Venue | {self.name}>"

to_dict()

Converts the venue data to a dictionary format.

Returns:

Name Type Description
dict dict

The raw JSON data representing the venue.

Source code in pyespn/classes/venue.py
def to_dict(self) -> dict:
    """
    Converts the venue data to a dictionary format.

    Returns:
        dict: The raw JSON data representing the venue.
    """
    return self.venue_json