Skip to content

base_container

Base Pydantic Object for Containers

CamplyModel #

Bases: BaseModel

Hashable Pydantic Model

Source code in camply/containers/base_container.py
class CamplyModel(BaseModel):
    """
    Hashable Pydantic Model
    """

    __unhashable__: Set[str] = set()

    def __hash__(self):
        """
        Hash Method for Pydantic BaseModels
        """
        return hash(self.__class__) + hash(
            tuple(
                value
                for key, value in self.__dict__.items()
                if key not in self.__unhashable__
            )
        )

    def __eq__(self, other: Any) -> bool:
        """
        Exclude Unhashable Fields When Evaluating Equality
        """
        if isinstance(other, CamplyModel):
            return self.dict(exclude=self.__unhashable__) == other.dict(
                exclude=other.__unhashable__
            )
        else:
            return self.dict(exclude=self.__unhashable__) == other

    class Config:
        """
        Camply Wide Configuration
        """

        anystr_strip_whitespace = True

Config #

Camply Wide Configuration

Source code in camply/containers/base_container.py
class Config:
    """
    Camply Wide Configuration
    """

    anystr_strip_whitespace = True

__eq__(other) #

Exclude Unhashable Fields When Evaluating Equality

Source code in camply/containers/base_container.py
def __eq__(self, other: Any) -> bool:
    """
    Exclude Unhashable Fields When Evaluating Equality
    """
    if isinstance(other, CamplyModel):
        return self.dict(exclude=self.__unhashable__) == other.dict(
            exclude=other.__unhashable__
        )
    else:
        return self.dict(exclude=self.__unhashable__) == other

__hash__() #

Hash Method for Pydantic BaseModels

Source code in camply/containers/base_container.py
def __hash__(self):
    """
    Hash Method for Pydantic BaseModels
    """
    return hash(self.__class__) + hash(
        tuple(
            value
            for key, value in self.__dict__.items()
            if key not in self.__unhashable__
        )
    )

GoingToCampEquipment #

Bases: CamplyModel

Model of GoingToCamp provider equipment

Source code in camply/containers/base_container.py
class GoingToCampEquipment(CamplyModel):
    """
    Model of GoingToCamp provider equipment
    """

    equipment_name: str
    equipment_type_id: int

RecDotGovAttribute #

Bases: CamplyModel

Attribute Object on the Recreation.gov Campsite

Source code in camply/containers/base_container.py
class RecDotGovAttribute(CamplyModel):
    """
    Attribute Object on the Recreation.gov Campsite
    """

    attribute_category: str
    attribute_id: int
    attribute_name: str
    attribute_value: Any

RecDotGovEquipment #

Bases: CamplyModel

Equipment Object on the Recreation.gov Campsite

Source code in camply/containers/base_container.py
class RecDotGovEquipment(CamplyModel):
    """
    Equipment Object on the Recreation.gov Campsite
    """

    equipment_name: str
    max_length: float