Skip to content

Constants

constants

BaseEnum

Bases: Enum

Base enum class for all enums in the library.

Extension

Represents an extension.

BerryExtension

Bases: Extension

Represents the berry extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories tuple[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 tuple[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 tuple[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 tuple[str, ...]

The categories of the extension.

GameExtension

Bases: Extension

Represents the game extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories tuple[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 tuple[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 tuple[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 tuple[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 tuple[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 tuple[str, ...]

The categories of the extension.

UtilityExtension

Bases: Extension

Represents the utility extension.

Attributes:

Name Type Description
name str

The name of the extension.

categories tuple[str, ...]

The categories of the extension.

ExtensionEnum

Bases: BaseEnum

validate_url classmethod

validate_url(url: str) -> RequestObject | None

Validate the url.

Source code in pokelance/constants.py
@classmethod
def validate_url(cls, url: str) -> RequestObject | None:
    """
    Validate the url.
    """
    if not url.startswith(get_base_url()) or not (groups := validate_url(url)):
        raise ValueError(f"Invalid url: {url}")
    category, value, subcategory = groups.groups()
    for i in cls:
        if category.lower() in i.value.categories:
            return RequestObject(extension=i.name, category=subcategory or category, value=value)
    raise ValueError(f"Invalid url: {url}")

Comments