Skip to content

Constants Module

anonipy.constants

Module containing the constants.

The constants module provides a set of predefined constants used in the package. These include supported languages, types of entities, and date transformation variants.

Classes:

Name Description
LANGUAGES

Predefined supported languages.

ENTITY_TYPES

Predefined types of entities.

DATE_TRANSFORM_VARIANTS

Predefined types of the date transformation variants.

LANGUAGES

The main anonipy supported languages.

Attributes:

Name Type Description
DUTCH Tuple[Literal[nl], Literal[Dutch]]

The Dutch language.

ENGLISH Tuple[Literal[en], Literal[English]]

The English language.

FRENCH Tuple[Literal[fr], Literal[French]]

The French language.

GERMAN Tuple[Literal[de], Literal[German]]

The German language.

GREEK Tuple[Literal[el], Literal[Greek]]

The Greek language.

ITALIAN Tuple[Literal[it], Literal[Italian]]

The Italian language.

SLOVENE Tuple[Literal[sl], Literal[Slovene]]

The Slovene language.

SPANISH Tuple[Literal[es], Literal[Spanish]]

The Spanish language.

UKRAINIAN Tuple[Literal[uk], Literal[Ukrainian]]

The Ukrainian language.

Methods:

Name Description
supported_languages

Return a list of supported languages.

Source code in anonipy/constants.py
class LANGUAGES:
    """The main anonipy supported languages.

    Attributes:
        DUTCH (Tuple[Literal["nl"], Literal["Dutch"]]): The Dutch language.
        ENGLISH (Tuple[Literal["en"], Literal["English"]]): The English language.
        FRENCH (Tuple[Literal["fr"], Literal["French"]]): The French language.
        GERMAN (Tuple[Literal["de"], Literal["German"]]): The German language.
        GREEK (Tuple[Literal["el"], Literal["Greek"]]): The Greek language.
        ITALIAN (Tuple[Literal["it"], Literal["Italian"]]): The Italian language.
        SLOVENE (Tuple[Literal["sl"], Literal["Slovene"]]): The Slovene language.
        SPANISH (Tuple[Literal["es"], Literal["Spanish"]]): The Spanish language.
        UKRAINIAN (Tuple[Literal["uk"], Literal["Ukrainian"]]): The Ukrainian language.

    Methods:
        supported_languages():
            Return a list of supported languages.

    """

    DUTCH = ("nl", "Dutch")
    ENGLISH = ("en", "English")
    FRENCH = ("fr", "French")
    GERMAN = ("de", "German")
    GREEK = ("el", "Greek")
    ITALIAN = ("it", "Italian")
    SLOVENE = ("sl", "Slovene")
    SPANISH = ("es", "Spanish")
    UKRAINIAN = ("uk", "Ukrainian")

    @classmethod
    def supported_languages(self) -> List[str]:
        """Return a list of supported languages.

        Returns:
            The list of supported languages.

        """
        return [lang[0] for lang in self.__dict__.values() if isinstance(lang, tuple)]

supported_languages() classmethod

Return a list of supported languages.

Returns:

Type Description
List[str]

The list of supported languages.

Source code in anonipy/constants.py
@classmethod
def supported_languages(self) -> List[str]:
    """Return a list of supported languages.

    Returns:
        The list of supported languages.

    """
    return [lang[0] for lang in self.__dict__.values() if isinstance(lang, tuple)]

ENTITY_TYPES

The anonipy supported entity types.

Attributes:

Name Type Description
CUSTOM Literal[custom]

The custom entity type.

STRING Literal[string]

The string entity type.

INTEGER Literal[integer]

The integer entity type.

FLOAT Literal[float]

The float entity type.

DATE Literal[date]

The date entity type.

EMAIL Literal[email]

The email entity type.

WEBSITE_URL Literal[website_url]

The website url entity type.

PHONE_NUMBER Literal[phone_number]

The phone number entity type.

Source code in anonipy/constants.py
class ENTITY_TYPES:
    """The anonipy supported entity types.

    Attributes:
        CUSTOM (Literal["custom"]): The custom entity type.
        STRING (Literal["string"]): The string entity type.
        INTEGER (Literal["integer"]): The integer entity type.
        FLOAT (Literal["float"]): The float entity type.
        DATE (Literal["date"]): The date entity type.
        EMAIL (Literal["email"]): The email entity type.
        WEBSITE_URL (Literal["website_url"]): The website url entity type.
        PHONE_NUMBER (Literal["phone_number"]): The phone number entity type.

    """

    CUSTOM = "custom"
    STRING = "string"
    INTEGER = "integer"
    FLOAT = "float"
    DATE = "date"
    EMAIL = "email"
    WEBSITE_URL = "website_url"
    PHONE_NUMBER = "phone_number"

DATE_TRANSFORM_VARIANTS

The supported date transform variants.

Attributes:

Name Type Description
FIRST_DAY_OF_THE_MONTH Literal[FIRST_DAY_OF_THE_MONTH]

The first day of the month.

LAST_DAY_OF_THE_MONTH Literal[LAST_DAY_OF_THE_MONTH]

The last day of the month.

MIDDLE_OF_THE_MONTH Literal[MIDDLE_OF_THE_MONTH]

The middle of the month.

MIDDLE_OF_THE_YEAR Literal[MIDDLE_OF_THE_YEAR]

The middle of the year.

RANDOM Literal[RANDOM]

A random date.

Methods:

Name Description
values

Return a list of all possible date transform variants.

is_valid

Check if the value is a valid date variant.

Source code in anonipy/constants.py
class DATE_TRANSFORM_VARIANTS:
    """The supported date transform variants.

    Attributes:
        FIRST_DAY_OF_THE_MONTH (Literal["FIRST_DAY_OF_THE_MONTH"]): The first day of the month.
        LAST_DAY_OF_THE_MONTH (Literal["LAST_DAY_OF_THE_MONTH"]): The last day of the month.
        MIDDLE_OF_THE_MONTH (Literal["MIDDLE_OF_THE_MONTH"]): The middle of the month.
        MIDDLE_OF_THE_YEAR (Literal["MIDDLE_OF_THE_YEAR"]): The middle of the year.
        RANDOM (Literal["RANDOM"]): A random date.

    Methods:
        values():
            Return a list of all possible date transform variants.
        is_valid(value):
            Check if the value is a valid date variant.

    """

    FIRST_DAY_OF_THE_MONTH = "FIRST_DAY_OF_THE_MONTH"
    LAST_DAY_OF_THE_MONTH = "LAST_DAY_OF_THE_MONTH"
    MIDDLE_OF_THE_MONTH = "MIDDLE_OF_THE_MONTH"
    MIDDLE_OF_THE_YEAR = "MIDDLE_OF_THE_YEAR"
    RANDOM = "RANDOM"

    @classmethod
    def values(self) -> List[str]:
        """Return a list of all possible date transform variants.

        Returns:
            The list of all possible variants.

        """
        return [
            self.FIRST_DAY_OF_THE_MONTH,
            self.LAST_DAY_OF_THE_MONTH,
            self.MIDDLE_OF_THE_MONTH,
            self.MIDDLE_OF_THE_YEAR,
            self.RANDOM,
        ]

    @classmethod
    def is_valid(self, value: str) -> bool:
        """Check if the value is a valid date variant.

        Args:
            value: The value to check.

        Returns:
            `True` if the value is a valid date variant, `False` otherwise.

        """
        return value in self.values()

values() classmethod

Return a list of all possible date transform variants.

Returns:

Type Description
List[str]

The list of all possible variants.

Source code in anonipy/constants.py
@classmethod
def values(self) -> List[str]:
    """Return a list of all possible date transform variants.

    Returns:
        The list of all possible variants.

    """
    return [
        self.FIRST_DAY_OF_THE_MONTH,
        self.LAST_DAY_OF_THE_MONTH,
        self.MIDDLE_OF_THE_MONTH,
        self.MIDDLE_OF_THE_YEAR,
        self.RANDOM,
    ]

is_valid(value) classmethod

Check if the value is a valid date variant.

Parameters:

Name Type Description Default
value str

The value to check.

required

Returns:

Type Description
bool

True if the value is a valid date variant, False otherwise.

Source code in anonipy/constants.py
@classmethod
def is_valid(self, value: str) -> bool:
    """Check if the value is a valid date variant.

    Args:
        value: The value to check.

    Returns:
        `True` if the value is a valid date variant, `False` otherwise.

    """
    return value in self.values()