How to use the mimesis.providers.base.BaseDataProvider function in mimesis

To help you get started, we’ve selected a few mimesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lk-geimfari / mimesis / tests / test_providers / test_base.py View on Github external
def test_setup_locale_unsupported_locale(self):
        with pytest.raises(UnsupportedLocale):
            BaseDataProvider(locale='nil')
github lk-geimfari / mimesis / tests / test_providers / test_base.py View on Github external
def test_pull_raises(self, locale):
        data_provider = BaseDataProvider(locale=locale)
        with pytest.raises(FileNotFoundError):
            data_provider.pull('something.json')
github lk-geimfari / mimesis / tests / test_providers / test_base.py View on Github external
def test_pull(self, locale, city):
        data_provider = BaseDataProvider(locale)
        data_provider.pull('address.json')
        assert city in data_provider._data['city']
github lk-geimfari / mimesis / mimesis / providers / date.py View on Github external
"""Provider of data related to date and time."""

from calendar import monthrange, timegm
from datetime import date, datetime, time, timedelta
from typing import List, Optional, Union

from mimesis.compat import pytz
from mimesis.data import GMT_OFFSETS, ROMAN_NUMS, TIMEZONES
from mimesis.providers.base import BaseDataProvider
from mimesis.typing import Date, DateTime, Time

__all__ = ['Datetime']


class Datetime(BaseDataProvider):
    """Class for generating data related to the date and time."""

    def __init__(self, *args, **kwargs):
        """Initialize attributes.

        :param locale: Current locale.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'datetime.json'
        self.pull(self._datafile)

    class Meta:
        """Class for metadata."""

        name = 'datetime'
github lk-geimfari / mimesis / mimesis / providers / structure.py View on Github external
from mimesis.data import (
    CSS_PROPERTIES,
    CSS_SELECTORS,
    CSS_SIZE_UNITS,
    HTML_CONTAINER_TAGS,
    HTML_MARKUP_TAGS,
)
from mimesis.providers.base import BaseDataProvider
from mimesis.providers.internet import Internet
from mimesis.providers.text import Text

__all__ = ['Structure']


class Structure(BaseDataProvider):
    """Class for generating structured data."""

    def __init__(self, *args, **kwargs) -> None:
        """Initialize attributes.

        :param locale: Current locale.
        :param seed: Seed.
        """
        super().__init__(*args, **kwargs)
        self.__inet = Internet(seed=self.seed)
        self.__text = Text('en', seed=self.seed)

    class Meta:
        """Class for metadata."""

        name = 'structure'
github lk-geimfari / mimesis / mimesis / providers / person.py View on Github external
CALLING_CODES,
    EMAIL_DOMAINS,
    GENDER_SYMBOLS,
    SEXUALITY_SYMBOLS,
    SOCIAL_NETWORKS,
    USERNAMES,
)
from mimesis.enums import Gender, SocialNetwork, TitleType
from mimesis.exceptions import NonEnumerableError
from mimesis.providers.base import BaseDataProvider
from mimesis.random import get_random_item

__all__ = ['Person']


class Person(BaseDataProvider):
    """Class for generating personal data."""

    def __init__(self, *args, **kwargs) -> None:
        """Initialize attributes.

        :param locale: Current locale.
        :param seed: Seed.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'person.json'
        self.pull(self._datafile)
        self._store = {
            'age': 0,
        }

    class Meta:
github lk-geimfari / mimesis / mimesis / providers / address.py View on Github external
from typing import Optional, Union

from mimesis.data import (
    CALLING_CODES,
    CONTINENT_CODES,
    COUNTRY_CODES,
    SHORTENED_ADDRESS_FMT,
)
from mimesis.enums import CountryCode
from mimesis.providers.base import BaseDataProvider

__all__ = ['Address']


class Address(BaseDataProvider):
    """Class for generate fake address data.

    This object provides all the data related to
    geographical location.
    """

    def __init__(self, *args, **kwargs) -> None:
        """Initialize attributes.

        :param locale: Current locale.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'address.json'
        self.pull(self._datafile)

    class Meta:
github lk-geimfari / mimesis / mimesis / providers / science.py View on Github external
# -*- coding: utf-8 -*-

"""Provides pseudo-scientific data."""

from typing import Union

from mimesis.data import MATH_FORMULAS
from mimesis.providers.base import BaseDataProvider

__all__ = ['Science']


class Science(BaseDataProvider):
    """Class for generating pseudo-scientific data."""

    def __init__(self, *args, **kwargs):
        """Initialize attributes.

        :param locale: Current language.
        :param seed: Seed.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'science.json'
        self.pull(self._datafile)

    class Meta:
        """Class for metadata."""

        name = 'science'
github lk-geimfari / mimesis / mimesis / providers / food.py View on Github external
# -*- coding: utf-8 -*-

"""Provides data related to food."""

from mimesis.providers.base import BaseDataProvider

__all__ = ['Food']


class Food(BaseDataProvider):
    """Class for generating data related to food."""

    def __init__(self, *args, **kwargs):
        """Initialize attributes.

        :param locale: Current locale.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'food.json'
        self.pull(self._datafile)

    class Meta:
        """Class for metadata."""

        name = 'food'
github lk-geimfari / mimesis / mimesis / providers / text.py View on Github external
# -*- coding: utf-8 -*-

"""Provides data related to text."""

from typing import List, Tuple

from mimesis.data import SAFE_COLORS
from mimesis.providers.base import BaseDataProvider

__all__ = ['Text']


class Text(BaseDataProvider):
    """Class for generating text data."""

    def __init__(self, *args, **kwargs):
        """Initialize attributes.

        :param locale: Current locale.
        :param seed: Seed.
        """
        super().__init__(*args, **kwargs)
        self._datafile = 'text.json'
        self.pull(self._datafile)

    class Meta:
        """Class for metadata."""

        name = 'text'