code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize fieldset. Accepts additional keyword argument **i** which is used to specify the number of iterations. The name of the keyword argument can be changed by overriding **fieldset_iterations_kwarg** attribute of t...
Initialize fieldset. Accepts additional keyword argument **i** which is used to specify the number of iterations. The name of the keyword argument can be changed by overriding **fieldset_iterations_kwarg** attribute of this class.
__init__
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def __call__(self, *args: Any, **kwargs: Any) -> list[Any]: """Perform fieldset. :param args: Arguments for field. :param kwargs: Keyword arguments for field. :raises FieldsetError: If parameter **i** is less than 1. :return: List of values. """ min_iterations = ...
Perform fieldset. :param args: Arguments for field. :param kwargs: Keyword arguments for field. :raises FieldsetError: If parameter **i** is less than 1. :return: List of values.
__call__
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def __init__(self, schema: CallableSchema, iterations: int = 10) -> None: """Initialize schema. :param iterations: Number of iterations. This parameter is keyword-only. The default value is 10. :param schema: A schema (must be a callable object). """ if iterations < ...
Initialize schema. :param iterations: Number of iterations. This parameter is keyword-only. The default value is 10. :param schema: A schema (must be a callable object).
__init__
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def to_csv(self, file_path: str, **kwargs: Any) -> None: """Export a schema as a CSV file. :param file_path: The file path. :param kwargs: The keyword arguments for :py:class:`csv.DictWriter` class. """ data = self.create() with open(file_path, "w", encoding="utf-8", new...
Export a schema as a CSV file. :param file_path: The file path. :param kwargs: The keyword arguments for :py:class:`csv.DictWriter` class.
to_csv
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def to_json(self, file_path: str, **kwargs: Any) -> None: """Export a schema as a JSON file. :param file_path: File a path. :param kwargs: Extra keyword arguments for :py:func:`json.dump` class. """ with open(file_path, "w", encoding="utf-8") as fp: json.dump(self.cr...
Export a schema as a JSON file. :param file_path: File a path. :param kwargs: Extra keyword arguments for :py:func:`json.dump` class.
to_json
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def to_pickle(self, file_path: str, **kwargs: Any) -> None: """Export a schema as the pickled representation of the object to the file. :param file_path: The file path. :param kwargs: Extra keyword arguments for :py:func:`pickle.dump` class. """ with open(file_path, "wb") as fp:...
Export a schema as the pickled representation of the object to the file. :param file_path: The file path. :param kwargs: Extra keyword arguments for :py:func:`pickle.dump` class.
to_pickle
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def __next__(self) -> JSON: """Return the next item from the iterator.""" if self.__counter < self.iterations: self.__counter += 1 return self.__schema() raise StopIteration
Return the next item from the iterator.
__next__
python
lk-geimfari/mimesis
mimesis/schema.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/schema.py
MIT
def luhn_checksum(num: str) -> str: """Calculate a checksum for num using the Luhn algorithm. Used to validate credit card numbers, IMEI numbers, and other identification numbers. :param num: The number to calculate a checksum for as a string. :return: Checksum for number. """ check = 0 ...
Calculate a checksum for num using the Luhn algorithm. Used to validate credit card numbers, IMEI numbers, and other identification numbers. :param num: The number to calculate a checksum for as a string. :return: Checksum for number.
luhn_checksum
python
lk-geimfari/mimesis
mimesis/shortcuts.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/shortcuts.py
MIT
def _calculate_checksum(self, cpr_nr_no_checksum: str) -> int: """Calculate the CPR number checksum. The CPR checksum can be checked by: 1. Multiplying each digit in the CPR number with a corresponding fixed factor (self._checksum_factors) to produce a list of products. 2. Su...
Calculate the CPR number checksum. The CPR checksum can be checked by: 1. Multiplying each digit in the CPR number with a corresponding fixed factor (self._checksum_factors) to produce a list of products. 2. Summing up all the products, including the checksum, and checking ...
_calculate_checksum
python
lk-geimfari/mimesis
mimesis/builtins/da.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/da.py
MIT
def _generate_serial_checksum(self, cpr_century: str) -> tuple[str, int]: """Generate a serial number and checksum from cpr_century.""" serial_number = f"{self.random.randint(0, 99):02d}" cpr_nr_no_checksum = f"{cpr_century}{serial_number}" checksum = self._calculate_checksum(cpr_nr_no_...
Generate a serial number and checksum from cpr_century.
_generate_serial_checksum
python
lk-geimfari/mimesis
mimesis/builtins/da.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/da.py
MIT
def cpr(self) -> str: """Generate a random CPR number (Central Person Registry). :return: CPR number. :Example: 0405420694 """ date = self._datetime.date(start=1858, end=2021) cpr_date = f"{date:%d%m%y}" century_selector = self._calculate_century_sel...
Generate a random CPR number (Central Person Registry). :return: CPR number. :Example: 0405420694
cpr
python
lk-geimfari/mimesis
mimesis/builtins/da.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/da.py
MIT
def tracking_number(self, service: str = "usps") -> str: """Generate random tracking number. Supported services: USPS, FedEx and UPS. :param str service: Post service. :return: Tracking number. """ service = service.lower() if service not in ("usps", "fedex", "...
Generate random tracking number. Supported services: USPS, FedEx and UPS. :param str service: Post service. :return: Tracking number.
tracking_number
python
lk-geimfari/mimesis
mimesis/builtins/en.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/en.py
MIT
def ssn(self) -> str: """Generate a random, but valid SSN. :returns: SSN. :Example: 569-66-5801 """ area = self.random.randint(1, 899) if area == 666: area = 665 return "{:03}-{:02}-{:04}".format( area, self.rando...
Generate a random, but valid SSN. :returns: SSN. :Example: 569-66-5801
ssn
python
lk-geimfari/mimesis
mimesis/builtins/en.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/en.py
MIT
def fiscal_code(self, gender: Gender | None = None) -> str: """Return a random fiscal code. :param gender: Gender's enum object. :return: Fiscal code. Example: RSSMRA66R05D612U """ code = "".join(self.random.choices(string.ascii_uppercase, k=6)) cod...
Return a random fiscal code. :param gender: Gender's enum object. :return: Fiscal code. Example: RSSMRA66R05D612U
fiscal_code
python
lk-geimfari/mimesis
mimesis/builtins/it.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/it.py
MIT
def bsn(self) -> str: """Generate a random, but valid ``Burgerservicenummer``. :returns: Random BSN. :Example: 255159705 """ def _is_valid_bsn(number: str) -> bool: total = 0 multiplier = 9 for char in number: mu...
Generate a random, but valid ``Burgerservicenummer``. :returns: Random BSN. :Example: 255159705
bsn
python
lk-geimfari/mimesis
mimesis/builtins/nl.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/nl.py
MIT
def nip(self) -> str: """Generate random valid 10-digit NIP. :return: Valid 10-digit NIP """ nip_digits = [int(d) for d in str(self.random.randint(101, 998))] nip_digits += [self.random.randint(0, 9) for _ in range(6)] nip_coefficients = (6, 5, 7, 2, 3, 4, 5, 6, 7) ...
Generate random valid 10-digit NIP. :return: Valid 10-digit NIP
nip
python
lk-geimfari/mimesis
mimesis/builtins/pl.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pl.py
MIT
def pesel( self, birth_date: DateTime | None = None, gender: Gender | None = None, ) -> str: """Generate random 11-digit PESEL. :param birth_date: Initial birthdate (optional) :param gender: Gender of the person. :return: Valid 11-digit PESEL """ ...
Generate random 11-digit PESEL. :param birth_date: Initial birthdate (optional) :param gender: Gender of the person. :return: Valid 11-digit PESEL
pesel
python
lk-geimfari/mimesis
mimesis/builtins/pl.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pl.py
MIT
def regon(self) -> str: """Generate random valid 9-digit REGON. :return: Valid 9-digit REGON """ regon_coeffs = (8, 9, 2, 3, 4, 5, 6, 7) regon_digits = [self.random.randint(0, 9) for _ in range(8)] sum_v = sum(nc * nd for nc, nd in zip(regon_coeffs, regon_digits)) ...
Generate random valid 9-digit REGON. :return: Valid 9-digit REGON
regon
python
lk-geimfari/mimesis
mimesis/builtins/pl.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pl.py
MIT
def __get_verifying_digit_cpf(cpf: list[int], weight: int) -> int: """Calculate the verifying digit for the CPF. :param cpf: List of integers with the CPF. :param weight: Integer with the weight for the modulo 11 calculate. :returns: The verifying digit for the CPF. """ ...
Calculate the verifying digit for the CPF. :param cpf: List of integers with the CPF. :param weight: Integer with the weight for the modulo 11 calculate. :returns: The verifying digit for the CPF.
__get_verifying_digit_cpf
python
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pt_br.py
MIT
def cpf(self, with_mask: bool = True) -> str: """Get a random CPF. :param with_mask: Use CPF mask (###.###.###-##). :returns: Random CPF. :Example: 001.137.297-40 """ cpf_without_dv = [self.random.randint(0, 9) for _ in range(9)] first_dv = self.__g...
Get a random CPF. :param with_mask: Use CPF mask (###.###.###-##). :returns: Random CPF. :Example: 001.137.297-40
cpf
python
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pt_br.py
MIT
def __get_verifying_digit_cnpj(cnpj: list[int], weight: int) -> int: """Calculate the verifying digit for the CNPJ. :param cnpj: List of integers with the CNPJ. :param weight: Integer with the weight for the modulo 11 calculate. :returns: The verifying digit for the CNPJ. """ ...
Calculate the verifying digit for the CNPJ. :param cnpj: List of integers with the CNPJ. :param weight: Integer with the weight for the modulo 11 calculate. :returns: The verifying digit for the CNPJ.
__get_verifying_digit_cnpj
python
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pt_br.py
MIT
def cnpj(self, with_mask: bool = True) -> str: """Get a random CNPJ. :param with_mask: Use cnpj mask (###.###.###-##) :returns: Random cnpj. :Example: 77.732.230/0001-70 """ cnpj_without_dv = [self.random.randint(0, 9) for _ in range(12)] first_dv ...
Get a random CNPJ. :param with_mask: Use cnpj mask (###.###.###-##) :returns: Random cnpj. :Example: 77.732.230/0001-70
cnpj
python
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/pt_br.py
MIT
def generate_sentence(self) -> str: """Generate sentence from the parts. :return: Sentence. """ sentences = self._extract(["sentence"]) sentence = [ self.random.choice(sentences[k]) for k in ("head", "p1", "p2", "tail") ] return " ".join(sentence)
Generate sentence from the parts. :return: Sentence.
generate_sentence
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def passport_series(self, year: int | None = None) -> str: """Generate random series of passport. :param year: Year of manufacture. :type year: int or None :return: Series. :Example: 02 15. """ if not year: year = self.random.randint(10, ...
Generate random series of passport. :param year: Year of manufacture. :type year: int or None :return: Series. :Example: 02 15.
passport_series
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def series_and_number(self) -> str: """Generate a random passport number and series. :return: Series and number. :Example: 57 16 805199. """ series = self.passport_series() number = self.passport_number() return f"{series} {number}"
Generate a random passport number and series. :return: Series and number. :Example: 57 16 805199.
series_and_number
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def snils(self) -> str: """Generate snils with a special algorithm. :return: SNILS. :Example: 41917492600. """ numbers = [] control_codes = [] for i in range(0, 9): numbers.append(self.random.randint(0, 9)) for i in range(9, 0, ...
Generate snils with a special algorithm. :return: SNILS. :Example: 41917492600.
snils
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def inn(self) -> str: """Generate random, but valid ``INN``. :return: INN. """ def control_sum(nums: list[int], t: str) -> int: digits_dict = { "n2": [7, 2, 4, 10, 3, 5, 9, 4, 6, 8], "n1": [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8], } ...
Generate random, but valid ``INN``. :return: INN.
inn
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def ogrn(self) -> str: """Generate random valid ``OGRN``. :return: OGRN. :Example: 4715113303725. """ numbers = [] for _ in range(0, 12): numbers.append(self.random.randint(1 if _ == 0 else 0, 9)) _ogrn = "".join(str(i) for i in numbers)...
Generate random valid ``OGRN``. :return: OGRN. :Example: 4715113303725.
ogrn
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def bic(self) -> str: """Generate random ``BIC`` (Bank ID Code). :return: BIC. :Example: 044025575. """ country_code = "04" code = f"{self.random.randint(1, 10):02}" bank_number = f"{self.random.randint(0, 99):02}" bank_office = f"{self.rando...
Generate random ``BIC`` (Bank ID Code). :return: BIC. :Example: 044025575.
bic
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def kpp(self) -> str: """Generate random ``KPP``. :return: 'KPP'. :Example: 560058652. """ tax_codes: list[str] = self._extract(["tax_codes"]) tax_code = tax_codes[self.random.randint(0, len(tax_codes) - 1)] reg_code = f"{self.random.randint(1, 99):0...
Generate random ``KPP``. :return: 'KPP'. :Example: 560058652.
kpp
python
lk-geimfari/mimesis
mimesis/builtins/ru.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/ru.py
MIT
def patronymic(self, gender: Gender | None = None) -> str: """Generate random patronymic name. :param gender: Gender of person. :type gender: str or int :return: Patronymic name. """ gender = self.validate_enum(gender, Gender) patronymics: list[str] = self._extra...
Generate random patronymic name. :param gender: Gender of person. :type gender: str or int :return: Patronymic name.
patronymic
python
lk-geimfari/mimesis
mimesis/builtins/uk.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/builtins/uk.py
MIT
def __init__( self, field: str, locale: Locale | None = None, **kwargs: Any, ) -> None: """ Creates a field instance. The created field is lazy. It also receives build time parameters. These parameters are not applied yet. :param field: name ...
Creates a field instance. The created field is lazy. It also receives build time parameters. These parameters are not applied yet. :param field: name to be passed to :class:`~mimesis.schema.Field`. :param locale: locale to use. This parameter has the highest priority. ...
__init__
python
lk-geimfari/mimesis
mimesis/plugins/factory.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/plugins/factory.py
MIT
def evaluate( self, instance: Resolver, step: BuildStep, extra: dict[str, Any] | None = None, ) -> Any: """Evaluates the lazy field. :param instance: (factory.builder.Resolver): The object holding currently computed attributes. :param step: (factory.builder.B...
Evaluates the lazy field. :param instance: (factory.builder.Resolver): The object holding currently computed attributes. :param step: (factory.builder.BuildStep): The object holding the current build step. :param extra: Extra call-time added kwargs that would be passed to ``Field``.
evaluate
python
lk-geimfari/mimesis
mimesis/plugins/factory.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/plugins/factory.py
MIT
def override_locale(cls, locale: Locale) -> Iterator[None]: """ Overrides unspecified locales. Remember that implicit locales would not be overridden. """ old_locale = cls._default_locale cls._default_locale = locale yield cls._default_locale = old_locale
Overrides unspecified locales. Remember that implicit locales would not be overridden.
override_locale
python
lk-geimfari/mimesis
mimesis/plugins/factory.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/plugins/factory.py
MIT
def _get_cached_instance( cls, locale: Locale | None = None, field_handlers: RegisterableFieldHandlers | None = None, ) -> Field: """Returns cached instance. :param locale: locale to use. :param field_handlers: custom field handlers. :return: cached instance ...
Returns cached instance. :param locale: locale to use. :param field_handlers: custom field handlers. :return: cached instance of Field.
_get_cached_instance
python
lk-geimfari/mimesis
mimesis/plugins/factory.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/plugins/factory.py
MIT
def address(self) -> str: """Generates a random full address. :return: Full address. """ fmt: str = self._extract(["address_fmt"]) st_num = self.street_number() st_name = self.street_name() if self.locale in SHORTENED_ADDRESS_FMT: return fmt.format(...
Generates a random full address. :return: Full address.
address
python
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/address.py
MIT
def state(self, abbr: bool = False) -> str: """Generates a random administrative district of the country. :param abbr: Return ISO 3166-2 code. :return: Administrative district. """ key = "abbr" if abbr else "name" states: list[str] = self._extract(["state", key]) ...
Generates a random administrative district of the country. :param abbr: Return ISO 3166-2 code. :return: Administrative district.
state
python
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/address.py
MIT
def _get_fs(self, key: str, dms: bool = False) -> str | float: """Get float number. :param key: Key (`lt` or `lg`). :param dms: DMS format. :return: Float number """ # The default range is a range of longitudes. rng = (-90, 90) if key == "lt" else (-180, 180) ...
Get float number. :param key: Key (`lt` or `lg`). :param dms: DMS format. :return: Float number
_get_fs
python
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/address.py
MIT
def coordinates(self, dms: bool = False) -> dict[str, str | float]: """Generates random geo coordinates. :param dms: DMS format. :return: Dict with coordinates. """ return { "longitude": self._get_fs("lg", dms), "latitude": self._get_fs("lt", dms), ...
Generates random geo coordinates. :param dms: DMS format. :return: Dict with coordinates.
coordinates
python
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/address.py
MIT
def continent(self, code: bool = False) -> str: """Returns a random continent name or continent code. :param code: Return code of a continent. :return: Continent name. """ codes: list[str] = self._extract(["continent"]) if code: codes = CONTINENT_CODES ...
Returns a random continent name or continent code. :param code: Return code of a continent. :return: Continent name.
continent
python
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/address.py
MIT
def __init__( self, *, seed: Seed = MissingSeed, random: _random.Random | None = None, ) -> None: """Initialize attributes. Keep in mind that locale-independent data providers will work only with keyword-only arguments. :param seed: Seed for random. ...
Initialize attributes. Keep in mind that locale-independent data providers will work only with keyword-only arguments. :param seed: Seed for random. When set to `None` the current system time is used. :param random: Custom random. See https://github.com/lk-geimf...
__init__
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def reseed(self, seed: Seed = MissingSeed) -> None: """Reseeds the internal random generator. In case we use the default seed, we need to create a per instance random generator. In this case, two providers with the same seed will always return the same values. :param seed: Seed...
Reseeds the internal random generator. In case we use the default seed, we need to create a per instance random generator. In this case, two providers with the same seed will always return the same values. :param seed: Seed for random. When set to `None` the current system ...
reseed
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def validate_enum(self, item: t.Any, enum: t.Any) -> t.Any: """Validates various enum objects that are used as arguments for methods. :param item: Item of an enum object. :param enum: Enum object. :return: Value of item. :raises NonEnumerableError: If enums has not such an item....
Validates various enum objects that are used as arguments for methods. :param item: Item of an enum object. :param enum: Enum object. :return: Value of item. :raises NonEnumerableError: If enums has not such an item.
validate_enum
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _read_global_file(self, file_name: str) -> t.Any: """Reads JSON file and return dict. Reads JSON file from mimesis/data/global/ directory. :param file_name: Path to file. :raises FileNotFoundError: If the file was not found. :return: JSON data. """ with open...
Reads JSON file and return dict. Reads JSON file from mimesis/data/global/ directory. :param file_name: Path to file. :raises FileNotFoundError: If the file was not found. :return: JSON data.
_read_global_file
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _has_seed(self) -> bool: """Internal API to check if seed is set.""" return (self.seed is not None and self.seed is not MissingSeed) or ( _random.global_seed is not None and _random.global_seed is not MissingSeed )
Internal API to check if seed is set.
_has_seed
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def __init__( self, locale: Locale = Locale.DEFAULT, seed: Seed = MissingSeed, *args: t.Any, **kwargs: t.Any, ) -> None: """Initialize attributes for data providers. :param locale: Current locale. :param seed: Seed to all the random functions. ...
Initialize attributes for data providers. :param locale: Current locale. :param seed: Seed to all the random functions.
__init__
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _setup_locale(self, locale: Locale = Locale.DEFAULT) -> None: """Set up locale after pre-check. :param str locale: Locale :raises UnsupportedLocale: When locale not supported. :return: Nothing. """ locale_obj = validate_locale(locale) self.locale = locale_ob...
Set up locale after pre-check. :param str locale: Locale :raises UnsupportedLocale: When locale not supported. :return: Nothing.
_setup_locale
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _extract(self, keys: list[str], default: t.Any = None) -> t.Any: """Extracts nested values from JSON file by list of keys. :param keys: List of keys (order extremely matters). :param default: Default value. :return: Data. """ if not keys: raise ValueError...
Extracts nested values from JSON file by list of keys. :param keys: List of keys (order extremely matters). :param default: Default value. :return: Data.
_extract
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _update_dict(self, initial: JSON, other: JSON) -> JSON: """Recursively updates a dictionary. :param initial: Dict to update. :param other: Dict to update from. :return: Updated dict. """ for k, v in other.items(): if isinstance(v, dict): i...
Recursively updates a dictionary. :param initial: Dict to update. :param other: Dict to update from. :return: Updated dict.
_update_dict
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def _load_dataset(self) -> None: """Loads the content from the JSON dataset. :return: The content of the file. :raises UnsupportedLocale: Raises if locale is unsupported. """ locale = self.locale datafile = getattr(self.Meta, "datafile", "") datadir = getattr(sel...
Loads the content from the JSON dataset. :return: The content of the file. :raises UnsupportedLocale: Raises if locale is unsupported.
_load_dataset
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def update_dataset(self, data: JSON) -> None: """Updates dataset merging a given dict into default data. This method may be useful when you need to override data for a given key in JSON file. """ if not isinstance(data, dict): raise TypeError("The data must be a dict...
Updates dataset merging a given dict into default data. This method may be useful when you need to override data for a given key in JSON file.
update_dataset
python
lk-geimfari/mimesis
mimesis/providers/base.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/base.py
MIT
def __call__( self, items: t.Sequence[t.Any] | None, length: int = 0, unique: bool = False, ) -> t.Sequence[t.Any] | t.Any: """Generates a randomly chosen sequence or bare element from a sequence. Provide elements randomly chosen from the elements in a sequence ...
Generates a randomly chosen sequence or bare element from a sequence. Provide elements randomly chosen from the elements in a sequence **items**, where when **length** is specified the random choices are contained in a sequence of the same type of length **length**, otherwise a single u...
__call__
python
lk-geimfari/mimesis
mimesis/providers/choice.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/choice.py
MIT
def isbn( self, fmt: ISBNFormat | None = None, locale: Locale = Locale.DEFAULT ) -> str: """Generates ISBN for current locale. To change ISBN format, pass parameter ``code`` with needed value of the enum object :class:`~mimesis.enums.ISBNFormat` :param fmt: ISBN format. ...
Generates ISBN for current locale. To change ISBN format, pass parameter ``code`` with needed value of the enum object :class:`~mimesis.enums.ISBNFormat` :param fmt: ISBN format. :param locale: Locale code. :return: ISBN. :raises NonEnumerableError: if code is not enum ...
isbn
python
lk-geimfari/mimesis
mimesis/providers/code.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/code.py
MIT
def ean(self, fmt: EANFormat | None = None) -> str: """Generates EAN. To change an EAN format, pass parameter ``code`` with needed value of the enum object :class:`~mimesis.enums.EANFormat`. :param fmt: Format of EAN. :return: EAN. :raises NonEnumerableError: if code is...
Generates EAN. To change an EAN format, pass parameter ``code`` with needed value of the enum object :class:`~mimesis.enums.EANFormat`. :param fmt: Format of EAN. :return: EAN. :raises NonEnumerableError: if code is not enum EANFormat.
ean
python
lk-geimfari/mimesis
mimesis/providers/code.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/code.py
MIT
def hash(self, algorithm: Algorithm | None = None) -> str: # noqa: A003 """Generates random hash. To change hashing algorithm, pass parameter ``algorithm`` with needed value of the enum object :class:`~mimesis.enums.Algorithm` :param algorithm: Enum object :class:`~mimesis.enums.Algor...
Generates random hash. To change hashing algorithm, pass parameter ``algorithm`` with needed value of the enum object :class:`~mimesis.enums.Algorithm` :param algorithm: Enum object :class:`~mimesis.enums.Algorithm`. :return: Hash. :raises NonEnumerableError: When algorithm is ...
hash
python
lk-geimfari/mimesis
mimesis/providers/cryptographic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/cryptographic.py
MIT
def mnemonic_phrase(self) -> str: """Generates BIP-39 looking mnemonic phrase. :return: Mnemonic phrase. """ length = self.random.choice([12, 24]) phrases = self.random.choices(WORDLIST, k=length) return " ".join(phrases)
Generates BIP-39 looking mnemonic phrase. :return: Mnemonic phrase.
mnemonic_phrase
python
lk-geimfari/mimesis
mimesis/providers/cryptographic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/cryptographic.py
MIT
def bulk_create_datetimes( date_start: DateTime, date_end: DateTime, **kwargs: t.Any, ) -> list[DateTime]: """Bulk create datetime objects. This method creates a list of datetime objects from ``date_start`` to ``date_end``. You can use the following keyword ...
Bulk create datetime objects. This method creates a list of datetime objects from ``date_start`` to ``date_end``. You can use the following keyword arguments: * ``days`` * ``hours`` * ``minutes`` * ``seconds`` * ``microseconds`` .. warning:: ...
bulk_create_datetimes
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def week_date(self, start: int = 2017, end: int = _CURRENT_YEAR) -> str: """Generates week number with year. :param start: Starting year. :param end: Ending year. :return: Week number. """ year = self.year(start, end) week = self.random.randint(1, 52) ret...
Generates week number with year. :param start: Starting year. :param end: Ending year. :return: Week number.
week_date
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def day_of_week(self, abbr: bool = False) -> str: """Generates a random day of the week. :param abbr: Abbreviated day name. :return: Day of the week. """ key = "abbr" if abbr else "name" days: list[str] = self._extract(["day", key]) return self.random.choice(days...
Generates a random day of the week. :param abbr: Abbreviated day name. :return: Day of the week.
day_of_week
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def month(self, abbr: bool = False) -> str: """Generates a random month of the year. :param abbr: Abbreviated month name. :return: Month name. """ key = "abbr" if abbr else "name" months: list[str] = self._extract(["month", key]) return self.random.choice(months)
Generates a random month of the year. :param abbr: Abbreviated month name. :return: Month name.
month
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def date(self, start: int = 2000, end: int = _CURRENT_YEAR) -> Date: """Generates a random date object. :param start: Minimum value of year. :param end: Maximum value of year. :return: Formatted date. """ year = self.random.randint(start, end) month = self.random...
Generates a random date object. :param start: Minimum value of year. :param end: Maximum value of year. :return: Formatted date.
date
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def formatted_date(self, fmt: str = "", **kwargs: t.Any) -> str: """Generates random date as string. :param fmt: The format of date, if None then use standard accepted in the current locale. :param kwargs: Keyword arguments for :meth:`~.date()` :return: Formatted date. ...
Generates random date as string. :param fmt: The format of date, if None then use standard accepted in the current locale. :param kwargs: Keyword arguments for :meth:`~.date()` :return: Formatted date.
formatted_date
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def time(self) -> Time: """Generates a random time object. :return: ``datetime.time`` object. """ random_time = time( self.random.randint(0, 23), self.random.randint(0, 59), self.random.randint(0, 59), self.random.randint(0, 999999), ...
Generates a random time object. :return: ``datetime.time`` object.
time
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def formatted_time(self, fmt: str = "") -> str: """Generates formatted time as string. :param fmt: The format of time, if None then use standard accepted in the current locale. :return: String formatted time. """ time_obj = self.time() if not fmt: ...
Generates formatted time as string. :param fmt: The format of time, if None then use standard accepted in the current locale. :return: String formatted time.
formatted_time
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def timezone(self, region: TimezoneRegion | None = None) -> str: """Generates a random timezone. :param region: Timezone region. :return: Timezone. """ region_name = self.validate_enum(region, TimezoneRegion) return self.random.choice( [tz for tz in TIMEZONES...
Generates a random timezone. :param region: Timezone region. :return: Timezone.
timezone
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def datetime( self, start: int = _CURRENT_YEAR, end: int = _CURRENT_YEAR, timezone: str | None = None, ) -> DateTime: """Generates random datetime. :param start: Minimum value of year. :param end: Maximum value of year. :param timezone: Set custom tim...
Generates random datetime. :param start: Minimum value of year. :param end: Maximum value of year. :param timezone: Set custom timezone (pytz required). :return: Datetime
datetime
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def formatted_datetime(self, fmt: str = "", **kwargs: t.Any) -> str: """Generates datetime string in human-readable format. :param fmt: Custom format (default is format for current locale) :param kwargs: Keyword arguments for :meth:`~.datetime()` :return: Formatted datetime string. ...
Generates datetime string in human-readable format. :param fmt: Custom format (default is format for current locale) :param kwargs: Keyword arguments for :meth:`~.datetime()` :return: Formatted datetime string.
formatted_datetime
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def timestamp( self, fmt: TimestampFormat = TimestampFormat.POSIX, **kwargs: t.Any ) -> str | int: """Generates a random timestamp in given format. Supported formats are: - TimestampFormat.POSIX - TimestampFormat.RFC_3339 - TimestampFormat.ISO_8601 Example:...
Generates a random timestamp in given format. Supported formats are: - TimestampFormat.POSIX - TimestampFormat.RFC_3339 - TimestampFormat.ISO_8601 Example: >>> from mimesis import Datetime >>> from mimesis.enums import TimestampFormat >>> dt = Datetime...
timestamp
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def duration( self, min_duration: int = 1, max_duration: int = 10, duration_unit: DurationUnit | None = DurationUnit.MINUTES, ) -> timedelta: """Generate a random duration. The default duration unit is Duration.MINUTES. When the duration unit is None, then r...
Generate a random duration. The default duration unit is Duration.MINUTES. When the duration unit is None, then random duration from DurationUnit is chosen. A timedelta object represents a duration, the difference between two datetime or date instances. :param min_dur...
duration
python
lk-geimfari/mimesis
mimesis/providers/date.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/date.py
MIT
def calver(self) -> str: """Generates a random calendar versioning string. :return: Calendar versioning string. :Example: 2016.11.08 """ year = self.random.randint(2016, datetime.now().year) month = self.random.randint(1, 12) day = self.random.randin...
Generates a random calendar versioning string. :return: Calendar versioning string. :Example: 2016.11.08
calver
python
lk-geimfari/mimesis
mimesis/providers/development.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/development.py
MIT
def extension(self, file_type: FileType | None = None) -> str: """Generates a random file extension. :param file_type: Enum object FileType. :return: Extension of the file. :Example: .py """ key = self.validate_enum(item=file_type, enum=FileType) ext...
Generates a random file extension. :param file_type: Enum object FileType. :return: Extension of the file. :Example: .py
extension
python
lk-geimfari/mimesis
mimesis/providers/file.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/file.py
MIT
def mime_type(self, type_: MimeType | None = None) -> str: """Generates a random mime type. :param type_: Enum object MimeType. :return: Mime type. """ key = self.validate_enum(item=type_, enum=MimeType) types = MIME_TYPES[key] return self.random.choice(types)
Generates a random mime type. :param type_: Enum object MimeType. :return: Mime type.
mime_type
python
lk-geimfari/mimesis
mimesis/providers/file.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/file.py
MIT
def size(self, minimum: int = 1, maximum: int = 100) -> str: """Generates a random file size as string. :param minimum: Maximum value. :param maximum: Minimum value. :return: Size of file. :Example: 56 kB """ num = self.random.randint(minimum, maximu...
Generates a random file size as string. :param minimum: Maximum value. :param maximum: Minimum value. :return: Size of file. :Example: 56 kB
size
python
lk-geimfari/mimesis
mimesis/providers/file.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/file.py
MIT
def file_name(self, file_type: FileType | None = None) -> str: """Generates a random file name with an extension. :param file_type: Enum object FileType :return: File name. :Example: legislative.txt """ ext = self.extension(file_type) name = self.ran...
Generates a random file name with an extension. :param file_type: Enum object FileType :return: File name. :Example: legislative.txt
file_name
python
lk-geimfari/mimesis
mimesis/providers/file.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/file.py
MIT
def company_type(self, abbr: bool = False) -> str: """Generates a random type of business entity. :param abbr: Abbreviated company type. :return: Types of business entity. """ key = "abbr" if abbr else "title" company_types: list[str] = self._extract(["company", "type",...
Generates a random type of business entity. :param abbr: Abbreviated company type. :return: Types of business entity.
company_type
python
lk-geimfari/mimesis
mimesis/providers/finance.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/finance.py
MIT
def currency_iso_code(self, allow_random: bool = False) -> str: """Returns a currency code for current locale. :param allow_random: Get a random ISO code. :return: Currency code. """ code: str = self._extract(["currency-code"]) if allow_random: return self.r...
Returns a currency code for current locale. :param allow_random: Get a random ISO code. :return: Currency code.
currency_iso_code
python
lk-geimfari/mimesis
mimesis/providers/finance.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/finance.py
MIT
def price(self, minimum: float = 500, maximum: float = 1500) -> float: """Generate a random price. :param minimum: Minimum value of price. :param maximum: Maximum value of price. :return: Price. """ return self.random.uniform( minimum, maximum, ...
Generate a random price. :param minimum: Minimum value of price. :param maximum: Maximum value of price. :return: Price.
price
python
lk-geimfari/mimesis
mimesis/providers/finance.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/finance.py
MIT
def price_in_btc(self, minimum: float = 0, maximum: float = 2) -> float: """Generates a random price in BTC. :param minimum: Minimum value of price. :param maximum: Maximum value of price. :return: Price in BTC. """ return self.random.uniform( minimum, ...
Generates a random price in BTC. :param minimum: Minimum value of price. :param maximum: Maximum value of price. :return: Price in BTC.
price_in_btc
python
lk-geimfari/mimesis
mimesis/providers/finance.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/finance.py
MIT
def __getattr__(self, attrname: str) -> t.Any: """Get attribute without an underscore. :param attrname: Attribute name. :return: An attribute. """ attribute = object.__getattribute__(self, "_" + attrname) if attribute and callable(attribute): self.__dict__[at...
Get attribute without an underscore. :param attrname: Attribute name. :return: An attribute.
__getattr__
python
lk-geimfari/mimesis
mimesis/providers/generic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/generic.py
MIT
def __dir__(self) -> list[str]: """Available data providers. :return: List of attributes. """ attributes = [] exclude = list(BaseProvider().__dict__.keys()) # Exclude locale explicitly because # it is not a provider. exclude.append("locale") for ...
Available data providers. :return: List of attributes.
__dir__
python
lk-geimfari/mimesis
mimesis/providers/generic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/generic.py
MIT
def reseed(self, seed: Seed = MissingSeed) -> None: """Reseed the internal random generator. Overrides method `BaseProvider.reseed()`. :param seed: Seed for random. :return: None. """ # Make sure to reseed the random generator on Generic itself. super().reseed(s...
Reseed the internal random generator. Overrides method `BaseProvider.reseed()`. :param seed: Seed for random. :return: None.
reseed
python
lk-geimfari/mimesis
mimesis/providers/generic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/generic.py
MIT
def add_provider(self, cls: t.Type[BaseProvider], **kwargs: t.Any) -> None: """Adds a custom provider to a Generic() object. :param cls: Custom provider. :param kwargs: Keyword arguments for provider. :raises TypeError: if cls is Generic, if cls is not class or is not a subc...
Adds a custom provider to a Generic() object. :param cls: Custom provider. :param kwargs: Keyword arguments for provider. :raises TypeError: if cls is Generic, if cls is not class or is not a subclass of BaseProvider. :return: Absolutely none.
add_provider
python
lk-geimfari/mimesis
mimesis/providers/generic.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/generic.py
MIT
def __init__(self, *args: t.Any, **kwargs: t.Any) -> None: """Initialize attributes. :param args: Arguments. :param kwargs: Keyword arguments. """ super().__init__(*args, **kwargs) self._file = File( seed=self.seed, random=self.random, ) ...
Initialize attributes. :param args: Arguments. :param kwargs: Keyword arguments.
__init__
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def dsn(self, dsn_type: DSNType | None = None, **kwargs: t.Any) -> str: """Generates a random DSN (Data Source Name). :param dsn_type: DSN type. :param kwargs: Additional keyword-arguments for hostname method. """ hostname = self.hostname(**kwargs) scheme, port = self.va...
Generates a random DSN (Data Source Name). :param dsn_type: DSN type. :param kwargs: Additional keyword-arguments for hostname method.
dsn
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def ip_v4_object(self) -> IPv4Address: """Generates a random :py:class:`ipaddress.IPv4Address` object. If you only need special purpose IPv4 addresses, use :meth:`special_ip_v4_object`. :return: :py:class:`ipaddress.IPv4Address` object. """ return IPv4Address( ...
Generates a random :py:class:`ipaddress.IPv4Address` object. If you only need special purpose IPv4 addresses, use :meth:`special_ip_v4_object`. :return: :py:class:`ipaddress.IPv4Address` object.
ip_v4_object
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def ip_v4_with_port(self, port_range: PortRange = PortRange.ALL) -> str: """Generates a random IPv4 address as string. :param port_range: PortRange enum object. :return: IPv4 address as string. :Example: 19.121.223.58:8000 """ addr = self.ip_v4() por...
Generates a random IPv4 address as string. :param port_range: PortRange enum object. :return: IPv4 address as string. :Example: 19.121.223.58:8000
ip_v4_with_port
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def ip_v6_object(self) -> IPv6Address: """Generates random :py:class:`ipaddress.IPv6Address` object. :return: :py:class:`ipaddress.IPv6Address` object. """ return IPv6Address( self.random.randint( 0, self._MAX_IPV6, ), )
Generates random :py:class:`ipaddress.IPv6Address` object. :return: :py:class:`ipaddress.IPv6Address` object.
ip_v6_object
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def asn(self) -> str: """Generates a random 4-byte ASN. ASNs reserved for private use are not considered. :return: ASN number as a string. :Example: AS123456 """ ranges = (1, 4_199_999_999) number = self.random.randint(*ranges) return f"AS{n...
Generates a random 4-byte ASN. ASNs reserved for private use are not considered. :return: ASN number as a string. :Example: AS123456
asn
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def mac_address(self) -> str: """Generates a random MAC address. :return: Random MAC address. :Example: 00:16:3e:25:e7:f1 """ mac_hex = [ 0x00, 0x16, 0x3E, self.random.randint(0x00, 0x7F), self.random.randi...
Generates a random MAC address. :return: Random MAC address. :Example: 00:16:3e:25:e7:f1
mac_address
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def hostname( self, tld_type: TLDType | None = None, subdomains: list[str] | None = None, ) -> str: """Generates a random hostname without a scheme. :param tld_type: TLDType. :param subdomains: List of subdomains (make sure they are valid). :return: Hostname....
Generates a random hostname without a scheme. :param tld_type: TLDType. :param subdomains: List of subdomains (make sure they are valid). :return: Hostname.
hostname
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def url( self, scheme: URLScheme | None = URLScheme.HTTPS, port_range: PortRange | None = None, tld_type: TLDType | None = None, subdomains: list[str] | None = None, ) -> str: """Generates a random URL. :param scheme: The scheme. :param port_range: Po...
Generates a random URL. :param scheme: The scheme. :param port_range: PortRange enum object. :param tld_type: TLDType. :param subdomains: List of subdomains (make sure they are valid). :return: URL.
url
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def uri( self, scheme: URLScheme | None = URLScheme.HTTPS, tld_type: TLDType | None = None, subdomains: list[str] | None = None, query_params_count: int | None = None, ) -> str: """Generates a random URI. :param scheme: Scheme. :param tld_type: TLDTyp...
Generates a random URI. :param scheme: Scheme. :param tld_type: TLDType. :param subdomains: List of subdomains (make sure they are valid). :param query_params_count: Query params. :return: URI.
uri
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def query_parameters(self, length: int | None = None) -> dict[str, str]: """Generates an arbitrary query parameters as a dict. :param length: Length of query parameters dictionary (maximum is 32). :return: Dict of query parameters. """ def pick_unique_words(quantity: int = 5) -...
Generates an arbitrary query parameters as a dict. :param length: Length of query parameters dictionary (maximum is 32). :return: Dict of query parameters.
query_parameters
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def slug(self, parts_count: int | None = None) -> str: """Generates a random slug of given parts count. :param parts_count: Slug's parts count. :return: Slug. """ if not parts_count: parts_count = self.random.randint(2, 12) if parts_count > 12: ...
Generates a random slug of given parts count. :param parts_count: Slug's parts count. :return: Slug.
slug
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def http_response_headers(self) -> dict[str, t.Any]: """Generates a random HTTP response headers. The following headers are included: - Allow - Age - Server - Content-Type - X-Request-ID - Content-Language - Content-Location - Set-Cookie ...
Generates a random HTTP response headers. The following headers are included: - Allow - Age - Server - Content-Type - X-Request-ID - Content-Language - Content-Location - Set-Cookie - Upgrade-Insecure-Requests - X-Content-Type-Opt...
http_response_headers
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def http_request_headers(self) -> dict[str, t.Any]: """Generates a random HTTP request headers. The following headers are included: - Referer - Authorization - Cookie - User-Agent - X-CSRF-Token - Content-Type - Content-Length - Connectio...
Generates a random HTTP request headers. The following headers are included: - Referer - Authorization - Cookie - User-Agent - X-CSRF-Token - Content-Type - Content-Length - Connection - Cache-Control - Accept - Host ...
http_request_headers
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def special_ip_v4_object(self, purpose: IPv4Purpose | None = None) -> IPv4Address: """Generates a special purpose IPv4 address. :param purpose: Enum object :class:`enums.IPv4Purpose`. :return: IPv4 address. :raises NonEnumerableError: if purpose not in :class:`enums.IPv4Purpose`. ...
Generates a special purpose IPv4 address. :param purpose: Enum object :class:`enums.IPv4Purpose`. :return: IPv4 address. :raises NonEnumerableError: if purpose not in :class:`enums.IPv4Purpose`.
special_ip_v4_object
python
lk-geimfari/mimesis
mimesis/providers/internet.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/internet.py
MIT
def increment(self, accumulator: str | None = None) -> int: """Generates an incrementing number. Each call of this method returns an incrementing number (with the step of +1). If **accumulator** passed then increments number associated with it. Example: >>> self.increment(...
Generates an incrementing number. Each call of this method returns an incrementing number (with the step of +1). If **accumulator** passed then increments number associated with it. Example: >>> self.increment() 1 >>> self.increment(accumulator="a") ...
increment
python
lk-geimfari/mimesis
mimesis/providers/numeric.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/numeric.py
MIT
def float_number( self, start: float = -1000.0, end: float = 1000.0, precision: int = 15 ) -> float: """Generates a random float number in range [start, end]. :param start: Start range. :param end: End range. :param precision: Round a number to a given precision...
Generates a random float number in range [start, end]. :param start: Start range. :param end: End range. :param precision: Round a number to a given precision in decimal digits, default is 15. :return: Float.
float_number
python
lk-geimfari/mimesis
mimesis/providers/numeric.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/numeric.py
MIT
def floats( self, start: float = 0, end: float = 1, n: int = 10, precision: int = 15 ) -> list[float]: """Generates a list of random float numbers. :param start: Start range. :param end: End range. :param n: Length of the list. :param precision: Round a number to a g...
Generates a list of random float numbers. :param start: Start range. :param end: End range. :param n: Length of the list. :param precision: Round a number to a given precision in decimal digits, default is 15. :return: The list of floating-point numbers.
floats
python
lk-geimfari/mimesis
mimesis/providers/numeric.py
https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/numeric.py
MIT