Skip to content

Constants

pokelance.constants ⚓︎

BaseEnum ⚓︎

Bases: Enum

Base enum class for all enums in the library.

__get__(instance, owner) ⚓︎

Get the value of the enum.

Source code in pokelance/constants.py
Python
def __get__(self, instance: t.Any, owner: t.Any) -> t.Any:
    """
    Get the value of the enum.
    """
    return self.value

BerryExtension ⚓︎

Bases: Extension

Represents the berry extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

ContestExtension ⚓︎

Bases: Extension

Represents the contest extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

EncounterExtension ⚓︎

Bases: Extension

Represents the encounter extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

EvolutionExtension ⚓︎

Bases: Extension

Represents the evolution extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

Extension ⚓︎

Represents an extension.

ExtensionEnum ⚓︎

Bases: BaseEnum

__get__(instance, owner) ⚓︎

Get the value of the enum.

Source code in pokelance/constants.py
Python
def __get__(self, instance: t.Any, owner: t.Any) -> t.Any:
    """
    Get the value of the enum.
    """
    return self.value

validate_url(url) classmethod ⚓︎

Validate the url.

Source code in pokelance/constants.py
Python
@classmethod
def validate_url(cls, url: str) -> t.Optional[RequestObject]:
    """
    Validate the url.
    """
    if not url.startswith("https://pokeapi.co/api/v2/") or not (groups := re.match(EXTENSION_PATTERN, url)):
        raise ValueError(f"Invalid url: {url}")
    category, value = groups.groups()
    for i in cls:
        if category.lower() in i.value.categories:
            return RequestObject(extension=i.name, category=category, value=value)
    raise ValueError(f"Invalid url: {url}")

GameExtension ⚓︎

Bases: Extension

Represents the game extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

ItemExtension ⚓︎

Bases: Extension

Represents the item extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

LocationExtension ⚓︎

Bases: Extension

Represents the location extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

MachineExtension ⚓︎

Bases: Extension

Represents the machine extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

MoveExtension ⚓︎

Bases: Extension

Represents the move extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

PokemonExtension ⚓︎

Bases: Extension

Represents the pokemon extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories List[str]

The categories of the extension.

ShowdownEnum ⚓︎

Bases: BaseEnum

Represents a showdown enum.

__get__(instance, owner) ⚓︎

Get the value of the enum.

Source code in pokelance/constants.py
Python
def __get__(self, instance: t.Any, owner: t.Any) -> t.Any:
    """
    Get the value of the enum.
    """
    return self.value