repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lk-geimfari/mimesis | mimesis/providers/internet.py | Internet.top_level_domain | def top_level_domain(self, tld_type: Optional[TLDType] = None) -> str:
"""Return random top level domain.
:param tld_type: Enum object DomainType
:return: Top level domain.
:raises NonEnumerableError: if tld_type not in DomainType.
"""
key = self._validate_enum(item=tld_... | python | def top_level_domain(self, tld_type: Optional[TLDType] = None) -> str:
"""Return random top level domain.
:param tld_type: Enum object DomainType
:return: Top level domain.
:raises NonEnumerableError: if tld_type not in DomainType.
"""
key = self._validate_enum(item=tld_... | [
"def",
"top_level_domain",
"(",
"self",
",",
"tld_type",
":",
"Optional",
"[",
"TLDType",
"]",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"item",
"=",
"tld_type",
",",
"enum",
"=",
"TLDType",
")",
"return",
"sel... | Return random top level domain.
:param tld_type: Enum object DomainType
:return: Top level domain.
:raises NonEnumerableError: if tld_type not in DomainType. | [
"Return",
"random",
"top",
"level",
"domain",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L226-L234 | train |
lk-geimfari/mimesis | mimesis/providers/internet.py | Internet.network_protocol | def network_protocol(self, layer: Optional[Layer] = None) -> str:
"""Get a random network protocol form OSI model.
:param layer: Enum object Layer.
:return: Protocol name.
:Example:
AMQP
"""
key = self._validate_enum(item=layer, enum=Layer)
protocols... | python | def network_protocol(self, layer: Optional[Layer] = None) -> str:
"""Get a random network protocol form OSI model.
:param layer: Enum object Layer.
:return: Protocol name.
:Example:
AMQP
"""
key = self._validate_enum(item=layer, enum=Layer)
protocols... | [
"def",
"network_protocol",
"(",
"self",
",",
"layer",
":",
"Optional",
"[",
"Layer",
"]",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"item",
"=",
"layer",
",",
"enum",
"=",
"Layer",
")",
"protocols",
"=",
"NET... | Get a random network protocol form OSI model.
:param layer: Enum object Layer.
:return: Protocol name.
:Example:
AMQP | [
"Get",
"a",
"random",
"network",
"protocol",
"form",
"OSI",
"model",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L247-L258 | train |
lk-geimfari/mimesis | mimesis/providers/internet.py | Internet.port | def port(self, port_range: PortRange = PortRange.ALL) -> int:
"""Generate random port.
:param port_range: Range enum object.
:return: Port number.
:raises NonEnumerableError: if port_range is not in PortRange.
:Example:
8080
"""
if port_range and por... | python | def port(self, port_range: PortRange = PortRange.ALL) -> int:
"""Generate random port.
:param port_range: Range enum object.
:return: Port number.
:raises NonEnumerableError: if port_range is not in PortRange.
:Example:
8080
"""
if port_range and por... | [
"def",
"port",
"(",
"self",
",",
"port_range",
":",
"PortRange",
"=",
"PortRange",
".",
"ALL",
")",
"->",
"int",
":",
"if",
"port_range",
"and",
"port_range",
"in",
"PortRange",
":",
"return",
"self",
".",
"random",
".",
"randint",
"(",
"*",
"port_range"... | Generate random port.
:param port_range: Range enum object.
:return: Port number.
:raises NonEnumerableError: if port_range is not in PortRange.
:Example:
8080 | [
"Generate",
"random",
"port",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L260-L273 | train |
lk-geimfari/mimesis | mimesis/providers/transport.py | Transport.truck | def truck(self, model_mask: str = '#### @@') -> str:
"""Generate a truck model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Dummy truck model.
:Example:
Caledon-966O.
"""
... | python | def truck(self, model_mask: str = '#### @@') -> str:
"""Generate a truck model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Dummy truck model.
:Example:
Caledon-966O.
"""
... | [
"def",
"truck",
"(",
"self",
",",
"model_mask",
":",
"str",
"=",
"'#### @@'",
")",
"->",
"str",
":",
"return",
"'{}-{}'",
".",
"format",
"(",
"self",
".",
"random",
".",
"choice",
"(",
"TRUCKS",
")",
",",
"self",
".",
"random",
".",
"custom_code",
"(... | Generate a truck model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Dummy truck model.
:Example:
Caledon-966O. | [
"Generate",
"a",
"truck",
"model",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L29-L42 | train |
lk-geimfari/mimesis | mimesis/providers/transport.py | Transport.airplane | def airplane(self, model_mask: str = '###') -> str:
"""Generate a dummy airplane model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Airplane model.
:Example:
Boeing 727.
"""... | python | def airplane(self, model_mask: str = '###') -> str:
"""Generate a dummy airplane model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Airplane model.
:Example:
Boeing 727.
"""... | [
"def",
"airplane",
"(",
"self",
",",
"model_mask",
":",
"str",
"=",
"'###'",
")",
"->",
"str",
":",
"model",
"=",
"self",
".",
"random",
".",
"custom_code",
"(",
"mask",
"=",
"model_mask",
")",
"plane",
"=",
"self",
".",
"random",
".",
"choice",
"(",... | Generate a dummy airplane model.
:param model_mask: Mask of truck model. Here '@' is a
placeholder of characters and '#' is a placeholder of digits.
:return: Airplane model.
:Example:
Boeing 727. | [
"Generate",
"a",
"dummy",
"airplane",
"model",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L54-L66 | train |
lk-geimfari/mimesis | mimesis/providers/transport.py | Transport.vehicle_registration_code | def vehicle_registration_code(self, locale: Optional[str] = None) -> str:
"""Get vehicle registration code of country.
:param locale: Registration code for locale (country).
:return: Vehicle registration code.
"""
if locale:
return VRC_BY_LOCALES[locale]
ret... | python | def vehicle_registration_code(self, locale: Optional[str] = None) -> str:
"""Get vehicle registration code of country.
:param locale: Registration code for locale (country).
:return: Vehicle registration code.
"""
if locale:
return VRC_BY_LOCALES[locale]
ret... | [
"def",
"vehicle_registration_code",
"(",
"self",
",",
"locale",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"locale",
":",
"return",
"VRC_BY_LOCALES",
"[",
"locale",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"("... | Get vehicle registration code of country.
:param locale: Registration code for locale (country).
:return: Vehicle registration code. | [
"Get",
"vehicle",
"registration",
"code",
"of",
"country",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L68-L77 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.bulk_create_datetimes | def bulk_create_datetimes(date_start: DateTime,
date_end: DateTime, **kwargs) -> List[DateTime]:
"""Bulk create datetime objects.
This method creates list of datetime objects from
``date_start`` to ``date_end``.
You can use the following keyword arguments:... | python | def bulk_create_datetimes(date_start: DateTime,
date_end: DateTime, **kwargs) -> List[DateTime]:
"""Bulk create datetime objects.
This method creates list of datetime objects from
``date_start`` to ``date_end``.
You can use the following keyword arguments:... | [
"def",
"bulk_create_datetimes",
"(",
"date_start",
":",
"DateTime",
",",
"date_end",
":",
"DateTime",
",",
"**",
"kwargs",
")",
"->",
"List",
"[",
"DateTime",
"]",
":",
"dt_objects",
"=",
"[",
"]",
"if",
"not",
"date_start",
"and",
"not",
"date_end",
":",
... | Bulk create datetime objects.
This method creates list of datetime objects from
``date_start`` to ``date_end``.
You can use the following keyword arguments:
* ``days``
* ``hours``
* ``minutes``
* ``seconds``
* ``microseconds``
See datetime modu... | [
"Bulk",
"create",
"datetime",
"objects",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L35-L73 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.week_date | def week_date(self, start: int = 2017, end: int = 2018) -> str:
"""Get week number with year.
:param start: From start.
:param end: To end.
:return: Week number.
"""
year = self.year(start, end)
week = self.random.randint(1, 52)
return '{year}-W{week}'.fo... | python | def week_date(self, start: int = 2017, end: int = 2018) -> str:
"""Get week number with year.
:param start: From start.
:param end: To end.
:return: Week number.
"""
year = self.year(start, end)
week = self.random.randint(1, 52)
return '{year}-W{week}'.fo... | [
"def",
"week_date",
"(",
"self",
",",
"start",
":",
"int",
"=",
"2017",
",",
"end",
":",
"int",
"=",
"2018",
")",
"->",
"str",
":",
"year",
"=",
"self",
".",
"year",
"(",
"start",
",",
"end",
")",
"week",
"=",
"self",
".",
"random",
".",
"randi... | Get week number with year.
:param start: From start.
:param end: To end.
:return: Week number. | [
"Get",
"week",
"number",
"with",
"year",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L75-L87 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.day_of_week | def day_of_week(self, abbr: bool = False) -> str:
"""Get a random day of week.
:param abbr: Abbreviated day name.
:return: Day of the week.
"""
key = 'abbr' if abbr else 'name'
days = self._data['day'].get(key)
return self.random.choice(days) | python | def day_of_week(self, abbr: bool = False) -> str:
"""Get a random day of week.
:param abbr: Abbreviated day name.
:return: Day of the week.
"""
key = 'abbr' if abbr else 'name'
days = self._data['day'].get(key)
return self.random.choice(days) | [
"def",
"day_of_week",
"(",
"self",
",",
"abbr",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"key",
"=",
"'abbr'",
"if",
"abbr",
"else",
"'name'",
"days",
"=",
"self",
".",
"_data",
"[",
"'day'",
"]",
".",
"get",
"(",
"key",
")",
"return",
"... | Get a random day of week.
:param abbr: Abbreviated day name.
:return: Day of the week. | [
"Get",
"a",
"random",
"day",
"of",
"week",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L89-L97 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.month | def month(self, abbr: bool = False) -> str:
"""Get a random month.
:param abbr: Abbreviated month name.
:return: Month name.
"""
key = 'abbr' if abbr else 'name'
months = self._data['month'].get(key)
return self.random.choice(months) | python | def month(self, abbr: bool = False) -> str:
"""Get a random month.
:param abbr: Abbreviated month name.
:return: Month name.
"""
key = 'abbr' if abbr else 'name'
months = self._data['month'].get(key)
return self.random.choice(months) | [
"def",
"month",
"(",
"self",
",",
"abbr",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"key",
"=",
"'abbr'",
"if",
"abbr",
"else",
"'name'",
"months",
"=",
"self",
".",
"_data",
"[",
"'month'",
"]",
".",
"get",
"(",
"key",
")",
"return",
"se... | Get a random month.
:param abbr: Abbreviated month name.
:return: Month name. | [
"Get",
"a",
"random",
"month",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L99-L107 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.year | def year(self, minimum: int = 1990, maximum: int = 2050) -> int:
"""Generate a random year.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Year.
"""
return self.random.randint(minimum, maximum) | python | def year(self, minimum: int = 1990, maximum: int = 2050) -> int:
"""Generate a random year.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Year.
"""
return self.random.randint(minimum, maximum) | [
"def",
"year",
"(",
"self",
",",
"minimum",
":",
"int",
"=",
"1990",
",",
"maximum",
":",
"int",
"=",
"2050",
")",
"->",
"int",
":",
"return",
"self",
".",
"random",
".",
"randint",
"(",
"minimum",
",",
"maximum",
")"
] | Generate a random year.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Year. | [
"Generate",
"a",
"random",
"year",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L109-L116 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.periodicity | def periodicity(self) -> str:
"""Get a random periodicity string.
:return: Periodicity.
"""
periodicity = self._data['periodicity']
return self.random.choice(periodicity) | python | def periodicity(self) -> str:
"""Get a random periodicity string.
:return: Periodicity.
"""
periodicity = self._data['periodicity']
return self.random.choice(periodicity) | [
"def",
"periodicity",
"(",
"self",
")",
"->",
"str",
":",
"periodicity",
"=",
"self",
".",
"_data",
"[",
"'periodicity'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"periodicity",
")"
] | Get a random periodicity string.
:return: Periodicity. | [
"Get",
"a",
"random",
"periodicity",
"string",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L125-L131 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.date | def date(self, start: int = 2000, end: int = 2019) -> Date:
"""Generate 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.randint(1, ... | python | def date(self, start: int = 2000, end: int = 2019) -> Date:
"""Generate 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.randint(1, ... | [
"def",
"date",
"(",
"self",
",",
"start",
":",
"int",
"=",
"2000",
",",
"end",
":",
"int",
"=",
"2019",
")",
"->",
"Date",
":",
"year",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"start",
",",
"end",
")",
"month",
"=",
"self",
".",
"rando... | Generate random date object.
:param start: Minimum value of year.
:param end: Maximum value of year.
:return: Formatted date. | [
"Generate",
"random",
"date",
"object",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L133-L144 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.formatted_date | def formatted_date(self, fmt: str = '', **kwargs) -> str:
"""Generate 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:`~Datetime.date()`
:return: Formatted date.
... | python | def formatted_date(self, fmt: str = '', **kwargs) -> str:
"""Generate 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:`~Datetime.date()`
:return: Formatted date.
... | [
"def",
"formatted_date",
"(",
"self",
",",
"fmt",
":",
"str",
"=",
"''",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"date_obj",
"=",
"self",
".",
"date",
"(",
"**",
"kwargs",
")",
"if",
"not",
"fmt",
":",
"fmt",
"=",
"self",
".",
"_data",
"[",
... | Generate 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:`~Datetime.date()`
:return: Formatted date. | [
"Generate",
"random",
"date",
"as",
"string",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L146-L159 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.time | def time(self) -> Time:
"""Generate 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),
... | python | def time(self) -> Time:
"""Generate 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),
... | [
"def",
"time",
"(",
"self",
")",
"->",
"Time",
":",
"random_time",
"=",
"time",
"(",
"self",
".",
"random",
".",
"randint",
"(",
"0",
",",
"23",
")",
",",
"self",
".",
"random",
".",
"randint",
"(",
"0",
",",
"59",
")",
",",
"self",
".",
"rando... | Generate a random time object.
:return: ``datetime.time`` object. | [
"Generate",
"a",
"random",
"time",
"object",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L161-L172 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.formatted_time | def formatted_time(self, fmt: str = '') -> str:
"""Generate string formatted time.
: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:
fm... | python | def formatted_time(self, fmt: str = '') -> str:
"""Generate string formatted time.
: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:
fm... | [
"def",
"formatted_time",
"(",
"self",
",",
"fmt",
":",
"str",
"=",
"''",
")",
"->",
"str",
":",
"time_obj",
"=",
"self",
".",
"time",
"(",
")",
"if",
"not",
"fmt",
":",
"fmt",
"=",
"self",
".",
"_data",
"[",
"'formats'",
"]",
".",
"get",
"(",
"... | Generate string formatted time.
:param fmt: The format of time, if None then use standard
accepted in the current locale.
:return: String formatted time. | [
"Generate",
"string",
"formatted",
"time",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L174-L185 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.datetime | def datetime(self, start: int = 2000, end: int = 2035,
timezone: Optional[str] = None) -> DateTime:
"""Generate random datetime.
:param start: Minimum value of year.
:param end: Maximum value of year.
:param timezone: Set custom timezone (pytz required).
:return... | python | def datetime(self, start: int = 2000, end: int = 2035,
timezone: Optional[str] = None) -> DateTime:
"""Generate random datetime.
:param start: Minimum value of year.
:param end: Maximum value of year.
:param timezone: Set custom timezone (pytz required).
:return... | [
"def",
"datetime",
"(",
"self",
",",
"start",
":",
"int",
"=",
"2000",
",",
"end",
":",
"int",
"=",
"2035",
",",
"timezone",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"DateTime",
":",
"datetime_obj",
"=",
"datetime",
".",
"combine",
... | Generate random datetime.
:param start: Minimum value of year.
:param end: Maximum value of year.
:param timezone: Set custom timezone (pytz required).
:return: Datetime | [
"Generate",
"random",
"datetime",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L208-L227 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.formatted_datetime | def formatted_datetime(self, fmt: str = '', **kwargs) -> str:
"""Generate datetime string in human readable format.
:param fmt: Custom format (default is format for current locale)
:param kwargs: Keyword arguments for :meth:`~Datetime.datetime()`
:return: Formatted datetime string.
... | python | def formatted_datetime(self, fmt: str = '', **kwargs) -> str:
"""Generate datetime string in human readable format.
:param fmt: Custom format (default is format for current locale)
:param kwargs: Keyword arguments for :meth:`~Datetime.datetime()`
:return: Formatted datetime string.
... | [
"def",
"formatted_datetime",
"(",
"self",
",",
"fmt",
":",
"str",
"=",
"''",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"dt_obj",
"=",
"self",
".",
"datetime",
"(",
"**",
"kwargs",
")",
"if",
"not",
"fmt",
":",
"date_fmt",
"=",
"self",
".",
"_data... | Generate datetime string in human readable format.
:param fmt: Custom format (default is format for current locale)
:param kwargs: Keyword arguments for :meth:`~Datetime.datetime()`
:return: Formatted datetime string. | [
"Generate",
"datetime",
"string",
"in",
"human",
"readable",
"format",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L229-L243 | train |
lk-geimfari/mimesis | mimesis/providers/date.py | Datetime.timestamp | def timestamp(self, posix: bool = True, **kwargs) -> Union[str, int]:
"""Generate random timestamp.
:param posix: POSIX time.
:param kwargs: Kwargs for :meth:`~Datetime.datetime()`.
:return: Timestamp.
"""
stamp = self.datetime(**kwargs)
if posix:
re... | python | def timestamp(self, posix: bool = True, **kwargs) -> Union[str, int]:
"""Generate random timestamp.
:param posix: POSIX time.
:param kwargs: Kwargs for :meth:`~Datetime.datetime()`.
:return: Timestamp.
"""
stamp = self.datetime(**kwargs)
if posix:
re... | [
"def",
"timestamp",
"(",
"self",
",",
"posix",
":",
"bool",
"=",
"True",
",",
"**",
"kwargs",
")",
"->",
"Union",
"[",
"str",
",",
"int",
"]",
":",
"stamp",
"=",
"self",
".",
"datetime",
"(",
"**",
"kwargs",
")",
"if",
"posix",
":",
"return",
"ti... | Generate random timestamp.
:param posix: POSIX time.
:param kwargs: Kwargs for :meth:`~Datetime.datetime()`.
:return: Timestamp. | [
"Generate",
"random",
"timestamp",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L245-L257 | train |
lk-geimfari/mimesis | mimesis/providers/cryptographic.py | Cryptographic.uuid | def uuid(self, version: int = None) -> str:
"""Generate random UUID.
:param version: UUID version.
:return: UUID
"""
bits = self.random.getrandbits(128)
return str(uuid.UUID(int=bits, version=version)) | python | def uuid(self, version: int = None) -> str:
"""Generate random UUID.
:param version: UUID version.
:return: UUID
"""
bits = self.random.getrandbits(128)
return str(uuid.UUID(int=bits, version=version)) | [
"def",
"uuid",
"(",
"self",
",",
"version",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"bits",
"=",
"self",
".",
"random",
".",
"getrandbits",
"(",
"128",
")",
"return",
"str",
"(",
"uuid",
".",
"UUID",
"(",
"int",
"=",
"bits",
",",
"version... | Generate random UUID.
:param version: UUID version.
:return: UUID | [
"Generate",
"random",
"UUID",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L32-L39 | train |
lk-geimfari/mimesis | mimesis/providers/cryptographic.py | Cryptographic.hash | def hash(self, algorithm: Algorithm = None) -> str: # noqa: A003
"""Generate 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`.
... | python | def hash(self, algorithm: Algorithm = None) -> str: # noqa: A003
"""Generate 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`.
... | [
"def",
"hash",
"(",
"self",
",",
"algorithm",
":",
"Algorithm",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"algorithm",
",",
"Algorithm",
")",
"if",
"hasattr",
"(",
"hashlib",
",",
"key",
")",
":",
"fn",
"=",
... | Generate 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: if algorithm is not... | [
"Generate",
"random",
"hash",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L41-L55 | train |
lk-geimfari/mimesis | mimesis/providers/cryptographic.py | Cryptographic.mnemonic_phrase | def mnemonic_phrase(self, length: int = 12) -> str:
"""Generate pseudo mnemonic phrase.
:param length: Number of words.
:return: Mnemonic code.
"""
words = self.__words['normal']
return ' '.join(self.random.choice(words) for _ in range(length)) | python | def mnemonic_phrase(self, length: int = 12) -> str:
"""Generate pseudo mnemonic phrase.
:param length: Number of words.
:return: Mnemonic code.
"""
words = self.__words['normal']
return ' '.join(self.random.choice(words) for _ in range(length)) | [
"def",
"mnemonic_phrase",
"(",
"self",
",",
"length",
":",
"int",
"=",
"12",
")",
"->",
"str",
":",
"words",
"=",
"self",
".",
"__words",
"[",
"'normal'",
"]",
"return",
"' '",
".",
"join",
"(",
"self",
".",
"random",
".",
"choice",
"(",
"words",
"... | Generate pseudo mnemonic phrase.
:param length: Number of words.
:return: Mnemonic code. | [
"Generate",
"pseudo",
"mnemonic",
"phrase",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L104-L111 | train |
lk-geimfari/mimesis | setup.py | Minimizer.initialize_options | def initialize_options(self):
"""Find all files of all locales."""
self.paths = []
self.separators = (',', ':')
self.data_dir = join(here, 'mimesis', 'data')
self.before_total = 0
self.after_total = 0
for root, _, files in os.walk(self.data_dir):
for ... | python | def initialize_options(self):
"""Find all files of all locales."""
self.paths = []
self.separators = (',', ':')
self.data_dir = join(here, 'mimesis', 'data')
self.before_total = 0
self.after_total = 0
for root, _, files in os.walk(self.data_dir):
for ... | [
"def",
"initialize_options",
"(",
"self",
")",
":",
"self",
".",
"paths",
"=",
"[",
"]",
"self",
".",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
"self",
".",
"data_dir",
"=",
"join",
"(",
"here",
",",
"'mimesis'",
",",
"'data'",
")",
"self",
"... | Find all files of all locales. | [
"Find",
"all",
"files",
"of",
"all",
"locales",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/setup.py#L34-L46 | train |
lk-geimfari/mimesis | setup.py | Minimizer.run | def run(self):
"""Start json minimizer and exit when all json files were minimized."""
for rel_path in sorted(self.paths):
file_path = join(self.data_dir, rel_path)
self.minify(file_path)
after = self.size_of(self.after_total)
before = self.size_of(self.before_to... | python | def run(self):
"""Start json minimizer and exit when all json files were minimized."""
for rel_path in sorted(self.paths):
file_path = join(self.data_dir, rel_path)
self.minify(file_path)
after = self.size_of(self.after_total)
before = self.size_of(self.before_to... | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"rel_path",
"in",
"sorted",
"(",
"self",
".",
"paths",
")",
":",
"file_path",
"=",
"join",
"(",
"self",
".",
"data_dir",
",",
"rel_path",
")",
"self",
".",
"minify",
"(",
"file_path",
")",
"after",
"=",
"... | Start json minimizer and exit when all json files were minimized. | [
"Start",
"json",
"minimizer",
"and",
"exit",
"when",
"all",
"json",
"files",
"were",
"minimized",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/setup.py#L92-L106 | train |
lk-geimfari/mimesis | mimesis/providers/structure.py | Structure.css | def css(self) -> str:
"""Generate a random snippet of CSS.
:return: CSS.
"""
selector = self.random.choice(CSS_SELECTORS)
css_sel = '{}{}'.format(selector, self.__text.word())
cont_tag = self.random.choice(list(HTML_CONTAINER_TAGS.keys()))
mrk_tag = self.random.... | python | def css(self) -> str:
"""Generate a random snippet of CSS.
:return: CSS.
"""
selector = self.random.choice(CSS_SELECTORS)
css_sel = '{}{}'.format(selector, self.__text.word())
cont_tag = self.random.choice(list(HTML_CONTAINER_TAGS.keys()))
mrk_tag = self.random.... | [
"def",
"css",
"(",
"self",
")",
"->",
"str",
":",
"selector",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"CSS_SELECTORS",
")",
"css_sel",
"=",
"'{}{}'",
".",
"format",
"(",
"selector",
",",
"self",
".",
"__text",
".",
"word",
"(",
")",
")",
"c... | Generate a random snippet of CSS.
:return: CSS. | [
"Generate",
"a",
"random",
"snippet",
"of",
"CSS",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L37-L51 | train |
lk-geimfari/mimesis | mimesis/providers/structure.py | Structure.css_property | def css_property(self) -> str:
"""Generate a random snippet of CSS that assigns value to a property.
:return: CSS property.
:Examples:
'background-color: #f4d3a1'
"""
prop = self.random.choice(list(CSS_PROPERTIES.keys()))
val = CSS_PROPERTIES[prop]
... | python | def css_property(self) -> str:
"""Generate a random snippet of CSS that assigns value to a property.
:return: CSS property.
:Examples:
'background-color: #f4d3a1'
"""
prop = self.random.choice(list(CSS_PROPERTIES.keys()))
val = CSS_PROPERTIES[prop]
... | [
"def",
"css_property",
"(",
"self",
")",
"->",
"str",
":",
"prop",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"list",
"(",
"CSS_PROPERTIES",
".",
"keys",
"(",
")",
")",
")",
"val",
"=",
"CSS_PROPERTIES",
"[",
"prop",
"]",
"if",
"isinstance",
"("... | Generate a random snippet of CSS that assigns value to a property.
:return: CSS property.
:Examples:
'background-color: #f4d3a1' | [
"Generate",
"a",
"random",
"snippet",
"of",
"CSS",
"that",
"assigns",
"value",
"to",
"a",
"property",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L53-L72 | train |
lk-geimfari/mimesis | mimesis/providers/structure.py | Structure.html | def html(self) -> str:
"""Generate a random HTML tag with text inside and some attrs set.
:return: HTML.
:Examples:
'<span class="select" id="careers">
Ports are created with the built-in function open_port.
</span>'
"""
tag_name = self.rando... | python | def html(self) -> str:
"""Generate a random HTML tag with text inside and some attrs set.
:return: HTML.
:Examples:
'<span class="select" id="careers">
Ports are created with the built-in function open_port.
</span>'
"""
tag_name = self.rando... | [
"def",
"html",
"(",
"self",
")",
"->",
"str",
":",
"tag_name",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"list",
"(",
"HTML_CONTAINER_TAGS",
")",
")",
"tag_attributes",
"=",
"list",
"(",
"HTML_CONTAINER_TAGS",
"[",
"tag_name",
"]",
")",
"k",
"=",
... | Generate a random HTML tag with text inside and some attrs set.
:return: HTML.
:Examples:
'<span class="select" id="careers">
Ports are created with the built-in function open_port.
</span>' | [
"Generate",
"a",
"random",
"HTML",
"tag",
"with",
"text",
"inside",
"and",
"some",
"attrs",
"set",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L74-L100 | train |
lk-geimfari/mimesis | mimesis/providers/structure.py | Structure.html_attribute_value | def html_attribute_value(self, tag: str = None,
attribute: str = None) -> str:
"""Generate random value for specified HTML tag attribute.
:param tag: An HTML tag.
:param attribute: An attribute of the specified tag.
:return: An attribute.
:raises Not... | python | def html_attribute_value(self, tag: str = None,
attribute: str = None) -> str:
"""Generate random value for specified HTML tag attribute.
:param tag: An HTML tag.
:param attribute: An attribute of the specified tag.
:return: An attribute.
:raises Not... | [
"def",
"html_attribute_value",
"(",
"self",
",",
"tag",
":",
"str",
"=",
"None",
",",
"attribute",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"if",
"not",
"tag",
":",
"tag",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"list",
"(",
"HTML_CO... | Generate random value for specified HTML tag attribute.
:param tag: An HTML tag.
:param attribute: An attribute of the specified tag.
:return: An attribute.
:raises NotImplementedError: if tag is unsupported. | [
"Generate",
"random",
"value",
"for",
"specified",
"HTML",
"tag",
"attribute",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L102-L138 | train |
lk-geimfari/mimesis | mimesis/providers/development.py | Development.version | def version(self, calver: bool = False, pre_release: bool = False) -> str:
"""Generate version number.
:param calver: Calendar versioning.
:param pre_release: Pre-release.
:return: Version.
:Example:
0.2.1
"""
# TODO: Optimize
version = '{}.{... | python | def version(self, calver: bool = False, pre_release: bool = False) -> str:
"""Generate version number.
:param calver: Calendar versioning.
:param pre_release: Pre-release.
:return: Version.
:Example:
0.2.1
"""
# TODO: Optimize
version = '{}.{... | [
"def",
"version",
"(",
"self",
",",
"calver",
":",
"bool",
"=",
"False",
",",
"pre_release",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"version",
"=",
"'{}.{}.{}'",
"major",
",",
"minor",
",",
"patch",
"=",
"self",
".",
"random",
".",
"randin... | Generate version number.
:param calver: Calendar versioning.
:param pre_release: Pre-release.
:return: Version.
:Example:
0.2.1 | [
"Generate",
"version",
"number",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/development.py#L29-L60 | train |
lk-geimfari/mimesis | mimesis/providers/science.py | Science.chemical_element | def chemical_element(self, name_only: bool = True) -> Union[dict, str]:
"""Generate a random chemical element.
:param name_only: If False then will be returned dict.
:return: Name of chemical element or dict.
:rtype: dict or str
:Example:
{'Symbol': 'S', 'Name': 'Su... | python | def chemical_element(self, name_only: bool = True) -> Union[dict, str]:
"""Generate a random chemical element.
:param name_only: If False then will be returned dict.
:return: Name of chemical element or dict.
:rtype: dict or str
:Example:
{'Symbol': 'S', 'Name': 'Su... | [
"def",
"chemical_element",
"(",
"self",
",",
"name_only",
":",
"bool",
"=",
"True",
")",
"->",
"Union",
"[",
"dict",
",",
"str",
"]",
":",
"elements",
"=",
"self",
".",
"_data",
"[",
"'chemical_element'",
"]",
"nm",
",",
"sm",
",",
"an",
"=",
"self",... | Generate a random chemical element.
:param name_only: If False then will be returned dict.
:return: Name of chemical element or dict.
:rtype: dict or str
:Example:
{'Symbol': 'S', 'Name': 'Sulfur', 'Atomic number': '16'} | [
"Generate",
"a",
"random",
"chemical",
"element",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/science.py#L42-L62 | train |
lk-geimfari/mimesis | mimesis/builtins/pt_br.py | BrazilSpecProvider.cpf | 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
"""
def get_verifying_digit_cpf(cpf, peso):
"""Calculate the verifying digit for th... | python | 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
"""
def get_verifying_digit_cpf(cpf, peso):
"""Calculate the verifying digit for th... | [
"def",
"cpf",
"(",
"self",
",",
"with_mask",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"def",
"get_verifying_digit_cpf",
"(",
"cpf",
",",
"peso",
")",
":",
"soma",
"=",
"0",
"for",
"index",
",",
"digit",
"in",
"enumerate",
"(",
"cpf",
")",
"... | Get a random CPF.
:param with_mask: Use CPF mask (###.###.###-##).
:returns: Random CPF.
:Example:
001.137.297-40 | [
"Get",
"a",
"random",
"CPF",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pt_br.py#L23-L58 | train |
lk-geimfari/mimesis | mimesis/builtins/pt_br.py | BrazilSpecProvider.cnpj | 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
"""
def get_verifying_digit_cnpj(cnpj, peso):
"""Calculate the verifying dig... | python | 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
"""
def get_verifying_digit_cnpj(cnpj, peso):
"""Calculate the verifying dig... | [
"def",
"cnpj",
"(",
"self",
",",
"with_mask",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"def",
"get_verifying_digit_cnpj",
"(",
"cnpj",
",",
"peso",
")",
":",
"soma",
"=",
"0",
"if",
"peso",
"==",
"5",
":",
"peso_list",
"=",
"[",
"5",
",",
... | Get a random CNPJ.
:param with_mask: Use cnpj mask (###.###.###-##)
:returns: Random cnpj.
:Example:
77.732.230/0001-70 | [
"Get",
"a",
"random",
"CNPJ",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pt_br.py#L60-L101 | train |
lk-geimfari/mimesis | mimesis/decorators.py | romanized | def romanized(locale: str = '') -> Callable:
"""Romanize the Cyrillic text.
Transliterate the Cyrillic language from the Cyrillic
script into the Latin alphabet.
.. note:: At this moment it works only for `ru`, `uk`, `kk`.
:param locale: Locale code.
:return: Latinized text.
"""
def r... | python | def romanized(locale: str = '') -> Callable:
"""Romanize the Cyrillic text.
Transliterate the Cyrillic language from the Cyrillic
script into the Latin alphabet.
.. note:: At this moment it works only for `ru`, `uk`, `kk`.
:param locale: Locale code.
:return: Latinized text.
"""
def r... | [
"def",
"romanized",
"(",
"locale",
":",
"str",
"=",
"''",
")",
"->",
"Callable",
":",
"def",
"romanized_deco",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":... | Romanize the Cyrillic text.
Transliterate the Cyrillic language from the Cyrillic
script into the Latin alphabet.
.. note:: At this moment it works only for `ru`, `uk`, `kk`.
:param locale: Locale code.
:return: Latinized text. | [
"Romanize",
"the",
"Cyrillic",
"text",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/decorators.py#L14-L44 | train |
lk-geimfari/mimesis | mimesis/providers/food.py | Food._choice_from | def _choice_from(self, key: str) -> str:
"""Choice random element."""
data = self._data[key]
return self.random.choice(data) | python | def _choice_from(self, key: str) -> str:
"""Choice random element."""
data = self._data[key]
return self.random.choice(data) | [
"def",
"_choice_from",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"str",
":",
"data",
"=",
"self",
".",
"_data",
"[",
"key",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"data",
")"
] | Choice random element. | [
"Choice",
"random",
"element",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/food.py#L27-L30 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.generate_sentence | def generate_sentence(self) -> str:
"""Generate sentence from the parts.
:return: Sentence.
"""
sentences = self._data['sentence']
sentence = [
self.random.choice(sentences[k]) for k
in ('head', 'p1', 'p2', 'tail')
]
return '{0} {1} {2} {3... | python | def generate_sentence(self) -> str:
"""Generate sentence from the parts.
:return: Sentence.
"""
sentences = self._data['sentence']
sentence = [
self.random.choice(sentences[k]) for k
in ('head', 'p1', 'p2', 'tail')
]
return '{0} {1} {2} {3... | [
"def",
"generate_sentence",
"(",
"self",
")",
"->",
"str",
":",
"sentences",
"=",
"self",
".",
"_data",
"[",
"'sentence'",
"]",
"sentence",
"=",
"[",
"self",
".",
"random",
".",
"choice",
"(",
"sentences",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"(",
... | Generate sentence from the parts.
:return: Sentence. | [
"Generate",
"sentence",
"from",
"the",
"parts",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L25-L35 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.patronymic | def patronymic(self, gender: Gender = None) -> str:
"""Generate random patronymic name.
:param gender: Gender of person.
:return: Patronymic name.
:Example:
Алексеевна.
"""
gender = self._validate_enum(gender, Gender)
patronymics = self._data['patron... | python | def patronymic(self, gender: Gender = None) -> str:
"""Generate random patronymic name.
:param gender: Gender of person.
:return: Patronymic name.
:Example:
Алексеевна.
"""
gender = self._validate_enum(gender, Gender)
patronymics = self._data['patron... | [
"def",
"patronymic",
"(",
"self",
",",
"gender",
":",
"Gender",
"=",
"None",
")",
"->",
"str",
":",
"gender",
"=",
"self",
".",
"_validate_enum",
"(",
"gender",
",",
"Gender",
")",
"patronymics",
"=",
"self",
".",
"_data",
"[",
"'patronymic'",
"]",
"["... | Generate random patronymic name.
:param gender: Gender of person.
:return: Patronymic name.
:Example:
Алексеевна. | [
"Generate",
"random",
"patronymic",
"name",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L37-L48 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.passport_series | def passport_series(self, year: int = 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, 18)
... | python | def passport_series(self, year: int = 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, 18)
... | [
"def",
"passport_series",
"(",
"self",
",",
"year",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"if",
"not",
"year",
":",
"year",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"10",
",",
"18",
")",
"region",
"=",
"self",
".",
"random",
"."... | Generate random series of passport.
:param year: Year of manufacture.
:type year: int or None
:return: Series.
:Example:
02 15. | [
"Generate",
"random",
"series",
"of",
"passport",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L50-L64 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.snils | def snils(self) -> str:
"""Generate snils with 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, -1... | python | def snils(self) -> str:
"""Generate snils with 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, -1... | [
"def",
"snils",
"(",
"self",
")",
"->",
"str",
":",
"numbers",
"=",
"[",
"]",
"control_codes",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"9",
")",
":",
"numbers",
".",
"append",
"(",
"self",
".",
"random",
".",
"randint",
"(",
"0... | Generate snils with special algorithm.
:return: SNILS.
:Example:
41917492600. | [
"Generate",
"snils",
"with",
"special",
"algorithm",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L90-L123 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.inn | def inn(self) -> str:
"""Generate random, but valid ``INN``.
:return: INN.
"""
def control_sum(nums: list, t: str) -> int:
digits = {
'n2': [7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
'n1': [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
}
nu... | python | def inn(self) -> str:
"""Generate random, but valid ``INN``.
:return: INN.
"""
def control_sum(nums: list, t: str) -> int:
digits = {
'n2': [7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
'n1': [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
}
nu... | [
"def",
"inn",
"(",
"self",
")",
"->",
"str",
":",
"def",
"control_sum",
"(",
"nums",
":",
"list",
",",
"t",
":",
"str",
")",
"->",
"int",
":",
"digits",
"=",
"{",
"'n2'",
":",
"[",
"7",
",",
"2",
",",
"4",
",",
"10",
",",
"3",
",",
"5",
"... | Generate random, but valid ``INN``.
:return: INN. | [
"Generate",
"random",
"but",
"valid",
"INN",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L125-L149 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.ogrn | 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(x) for x in numbers]... | python | 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(x) for x in numbers]... | [
"def",
"ogrn",
"(",
"self",
")",
"->",
"str",
":",
"numbers",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"12",
")",
":",
"numbers",
".",
"append",
"(",
"self",
".",
"random",
".",
"randint",
"(",
"1",
"if",
"_",
"==",
"0",
"else... | Generate random valid ``OGRN``.
:return: OGRN.
:Example:
4715113303725. | [
"Generate",
"random",
"valid",
"OGRN",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L151-L166 | train |
lk-geimfari/mimesis | mimesis/builtins/ru.py | RussiaSpecProvider.kpp | def kpp(self) -> str:
"""Generate random ``KPP``.
:return: 'KPP'.
:Example:
560058652.
"""
tax_codes = [
'7700', '7800', '5000', '0100',
'0200', '0300', '0500', '0600',
'0700', '0800', '0900', '1000',
'1100', '1200', '... | python | def kpp(self) -> str:
"""Generate random ``KPP``.
:return: 'KPP'.
:Example:
560058652.
"""
tax_codes = [
'7700', '7800', '5000', '0100',
'0200', '0300', '0500', '0600',
'0700', '0800', '0900', '1000',
'1100', '1200', '... | [
"def",
"kpp",
"(",
"self",
")",
"->",
"str",
":",
"tax_codes",
"=",
"[",
"'7700'",
",",
"'7800'",
",",
"'5000'",
",",
"'0100'",
",",
"'0200'",
",",
"'0300'",
",",
"'0500'",
",",
"'0600'",
",",
"'0700'",
",",
"'0800'",
",",
"'0900'",
",",
"'1000'",
... | Generate random ``KPP``.
:return: 'KPP'.
:Example:
560058652. | [
"Generate",
"random",
"KPP",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L183-L224 | train |
lk-geimfari/mimesis | mimesis/providers/hardware.py | Hardware.cpu_frequency | def cpu_frequency(self) -> str:
"""Get a random frequency of CPU.
:return: Frequency of CPU.
:Example:
4.0 GHz.
"""
return '{}GHz'.format(
self.random.uniform(
a=1.5,
b=4.3,
precision=1,
),
... | python | def cpu_frequency(self) -> str:
"""Get a random frequency of CPU.
:return: Frequency of CPU.
:Example:
4.0 GHz.
"""
return '{}GHz'.format(
self.random.uniform(
a=1.5,
b=4.3,
precision=1,
),
... | [
"def",
"cpu_frequency",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'{}GHz'",
".",
"format",
"(",
"self",
".",
"random",
".",
"uniform",
"(",
"a",
"=",
"1.5",
",",
"b",
"=",
"4.3",
",",
"precision",
"=",
"1",
",",
")",
",",
")"
] | Get a random frequency of CPU.
:return: Frequency of CPU.
:Example:
4.0 GHz. | [
"Get",
"a",
"random",
"frequency",
"of",
"CPU",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/hardware.py#L62-L76 | train |
lk-geimfari/mimesis | mimesis/providers/numbers.py | Numbers.floats | def floats(self, n: int = 2) -> List[float]:
"""Generate a list of random float numbers.
:param n: Raise 10 to the 'n' power.
:return: The list of floating-point numbers.
"""
nums = [self.random.random()
for _ in range(10 ** int(n))]
return nums | python | def floats(self, n: int = 2) -> List[float]:
"""Generate a list of random float numbers.
:param n: Raise 10 to the 'n' power.
:return: The list of floating-point numbers.
"""
nums = [self.random.random()
for _ in range(10 ** int(n))]
return nums | [
"def",
"floats",
"(",
"self",
",",
"n",
":",
"int",
"=",
"2",
")",
"->",
"List",
"[",
"float",
"]",
":",
"nums",
"=",
"[",
"self",
".",
"random",
".",
"random",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"10",
"**",
"int",
"(",
"n",
")",
")"... | Generate a list of random float numbers.
:param n: Raise 10 to the 'n' power.
:return: The list of floating-point numbers. | [
"Generate",
"a",
"list",
"of",
"random",
"float",
"numbers",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L20-L28 | train |
lk-geimfari/mimesis | mimesis/providers/numbers.py | Numbers.integers | def integers(self, start: int = 0, end: int = 10,
length: int = 10) -> List[int]:
"""Generate a list of random integers.
Integers can be negative or positive numbers.
.. note: You can use both positive and negative numbers.
:param start: Start.
:param end: End.... | python | def integers(self, start: int = 0, end: int = 10,
length: int = 10) -> List[int]:
"""Generate a list of random integers.
Integers can be negative or positive numbers.
.. note: You can use both positive and negative numbers.
:param start: Start.
:param end: End.... | [
"def",
"integers",
"(",
"self",
",",
"start",
":",
"int",
"=",
"0",
",",
"end",
":",
"int",
"=",
"10",
",",
"length",
":",
"int",
"=",
"10",
")",
"->",
"List",
"[",
"int",
"]",
":",
"return",
"self",
".",
"random",
".",
"randints",
"(",
"length... | Generate a list of random integers.
Integers can be negative or positive numbers.
.. note: You can use both positive and negative numbers.
:param start: Start.
:param end: End.
:param length: Length of list.
:return: List of integers.
:Example:
[-20... | [
"Generate",
"a",
"list",
"of",
"random",
"integers",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L30-L46 | train |
lk-geimfari/mimesis | mimesis/providers/numbers.py | Numbers.primes | def primes(start: int = 1, end: int = 999) -> List[int]:
"""Generate a list of prime numbers.
:param start: First value of range.
:param end: Last value of range.
:return: A list of prime numbers from start to end.
"""
# TODO: It should generate random primes with passed... | python | def primes(start: int = 1, end: int = 999) -> List[int]:
"""Generate a list of prime numbers.
:param start: First value of range.
:param end: Last value of range.
:return: A list of prime numbers from start to end.
"""
# TODO: It should generate random primes with passed... | [
"def",
"primes",
"(",
"start",
":",
"int",
"=",
"1",
",",
"end",
":",
"int",
"=",
"999",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sieve_size",
"=",
"(",
"end",
"//",
"2",
"-",
"1",
")",
"if",
"end",
"%",
"2",
"==",
"0",
"else",
"(",
"end",... | Generate a list of prime numbers.
:param start: First value of range.
:param end: Last value of range.
:return: A list of prime numbers from start to end. | [
"Generate",
"a",
"list",
"of",
"prime",
"numbers",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L49-L76 | train |
lk-geimfari/mimesis | mimesis/providers/numbers.py | Numbers.digit | def digit(self, to_bin: bool = False) -> Union[str, int]:
"""Get a random digit.
:param to_bin: If True then convert to binary.
:return: Digit.
:Example:
4.
"""
digit = self.random.randint(0, 9)
if to_bin:
return bin(digit)
retu... | python | def digit(self, to_bin: bool = False) -> Union[str, int]:
"""Get a random digit.
:param to_bin: If True then convert to binary.
:return: Digit.
:Example:
4.
"""
digit = self.random.randint(0, 9)
if to_bin:
return bin(digit)
retu... | [
"def",
"digit",
"(",
"self",
",",
"to_bin",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"str",
",",
"int",
"]",
":",
"digit",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"0",
",",
"9",
")",
"if",
"to_bin",
":",
"return",
"bin",
"("... | Get a random digit.
:param to_bin: If True then convert to binary.
:return: Digit.
:Example:
4. | [
"Get",
"a",
"random",
"digit",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L78-L92 | train |
lk-geimfari/mimesis | mimesis/providers/numbers.py | Numbers.between | def between(self, minimum: int = 1, maximum: int = 1000) -> int:
"""Generate a random number between minimum and maximum.
:param minimum: Minimum of range.
:param maximum: Maximum of range.
:return: Number.
"""
return self.random.randint(minimum, maximum) | python | def between(self, minimum: int = 1, maximum: int = 1000) -> int:
"""Generate a random number between minimum and maximum.
:param minimum: Minimum of range.
:param maximum: Maximum of range.
:return: Number.
"""
return self.random.randint(minimum, maximum) | [
"def",
"between",
"(",
"self",
",",
"minimum",
":",
"int",
"=",
"1",
",",
"maximum",
":",
"int",
"=",
"1000",
")",
"->",
"int",
":",
"return",
"self",
".",
"random",
".",
"randint",
"(",
"minimum",
",",
"maximum",
")"
] | Generate a random number between minimum and maximum.
:param minimum: Minimum of range.
:param maximum: Maximum of range.
:return: Number. | [
"Generate",
"a",
"random",
"number",
"between",
"minimum",
"and",
"maximum",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L94-L101 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.age | def age(self, minimum: int = 16, maximum: int = 66) -> int:
"""Get a random integer value.
:param maximum: Maximum value of age.
:param minimum: Minimum value of age.
:return: Random integer.
:Example:
23.
"""
age = self.random.randint(minimum, maxim... | python | def age(self, minimum: int = 16, maximum: int = 66) -> int:
"""Get a random integer value.
:param maximum: Maximum value of age.
:param minimum: Minimum value of age.
:return: Random integer.
:Example:
23.
"""
age = self.random.randint(minimum, maxim... | [
"def",
"age",
"(",
"self",
",",
"minimum",
":",
"int",
"=",
"16",
",",
"maximum",
":",
"int",
"=",
"66",
")",
"->",
"int",
":",
"age",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"minimum",
",",
"maximum",
")",
"self",
".",
"_store",
"[",
... | Get a random integer value.
:param maximum: Maximum value of age.
:param minimum: Minimum value of age.
:return: Random integer.
:Example:
23. | [
"Get",
"a",
"random",
"integer",
"value",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L48-L60 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.work_experience | def work_experience(self, working_start_age: int = 22) -> int:
"""Get a work experience.
:param working_start_age: Age then person start to work.
:return: Depend on previous generated age.
"""
age = self._store['age']
if age == 0:
age = self.age()
re... | python | def work_experience(self, working_start_age: int = 22) -> int:
"""Get a work experience.
:param working_start_age: Age then person start to work.
:return: Depend on previous generated age.
"""
age = self._store['age']
if age == 0:
age = self.age()
re... | [
"def",
"work_experience",
"(",
"self",
",",
"working_start_age",
":",
"int",
"=",
"22",
")",
"->",
"int",
":",
"age",
"=",
"self",
".",
"_store",
"[",
"'age'",
"]",
"if",
"age",
"==",
"0",
":",
"age",
"=",
"self",
".",
"age",
"(",
")",
"return",
... | Get a work experience.
:param working_start_age: Age then person start to work.
:return: Depend on previous generated age. | [
"Get",
"a",
"work",
"experience",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L62-L72 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.name | def name(self, gender: Optional[Gender] = None) -> str:
"""Generate a random name.
:param gender: Gender's enum object.
:return: Name.
:Example:
John.
"""
key = self._validate_enum(gender, Gender)
names = self._data['names'].get(key)
return s... | python | def name(self, gender: Optional[Gender] = None) -> str:
"""Generate a random name.
:param gender: Gender's enum object.
:return: Name.
:Example:
John.
"""
key = self._validate_enum(gender, Gender)
names = self._data['names'].get(key)
return s... | [
"def",
"name",
"(",
"self",
",",
"gender",
":",
"Optional",
"[",
"Gender",
"]",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"gender",
",",
"Gender",
")",
"names",
"=",
"self",
".",
"_data",
"[",
"'names'",
"]... | Generate a random name.
:param gender: Gender's enum object.
:return: Name.
:Example:
John. | [
"Generate",
"a",
"random",
"name",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L74-L85 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.surname | def surname(self, gender: Optional[Gender] = None) -> str:
"""Generate a random surname.
:param gender: Gender's enum object.
:return: Surname.
:Example:
Smith.
"""
surnames = self._data['surnames']
# Surnames separated by gender.
if isinsta... | python | def surname(self, gender: Optional[Gender] = None) -> str:
"""Generate a random surname.
:param gender: Gender's enum object.
:return: Surname.
:Example:
Smith.
"""
surnames = self._data['surnames']
# Surnames separated by gender.
if isinsta... | [
"def",
"surname",
"(",
"self",
",",
"gender",
":",
"Optional",
"[",
"Gender",
"]",
"=",
"None",
")",
"->",
"str",
":",
"surnames",
"=",
"self",
".",
"_data",
"[",
"'surnames'",
"]",
"if",
"isinstance",
"(",
"surnames",
",",
"dict",
")",
":",
"key",
... | Generate a random surname.
:param gender: Gender's enum object.
:return: Surname.
:Example:
Smith. | [
"Generate",
"a",
"random",
"surname",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L87-L103 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.title | def title(self, gender: Optional[Gender] = None,
title_type: Optional[TitleType] = None) -> str:
"""Generate a random title for name.
You can generate random prefix or suffix
for name using this method.
:param gender: The gender.
:param title_type: TitleType enum ... | python | def title(self, gender: Optional[Gender] = None,
title_type: Optional[TitleType] = None) -> str:
"""Generate a random title for name.
You can generate random prefix or suffix
for name using this method.
:param gender: The gender.
:param title_type: TitleType enum ... | [
"def",
"title",
"(",
"self",
",",
"gender",
":",
"Optional",
"[",
"Gender",
"]",
"=",
"None",
",",
"title_type",
":",
"Optional",
"[",
"TitleType",
"]",
"=",
"None",
")",
"->",
"str",
":",
"gender_key",
"=",
"self",
".",
"_validate_enum",
"(",
"gender"... | Generate a random title for name.
You can generate random prefix or suffix
for name using this method.
:param gender: The gender.
:param title_type: TitleType enum object.
:return: The title.
:raises NonEnumerableError: if gender or title_type in incorrect format.
... | [
"Generate",
"a",
"random",
"title",
"for",
"name",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L115-L134 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.full_name | def full_name(self, gender: Optional[Gender] = None,
reverse: bool = False) -> str:
"""Generate a random full name.
:param reverse: Return reversed full name.
:param gender: Gender's enum object.
:return: Full name.
:Example:
Johann Wolfgang.
... | python | def full_name(self, gender: Optional[Gender] = None,
reverse: bool = False) -> str:
"""Generate a random full name.
:param reverse: Return reversed full name.
:param gender: Gender's enum object.
:return: Full name.
:Example:
Johann Wolfgang.
... | [
"def",
"full_name",
"(",
"self",
",",
"gender",
":",
"Optional",
"[",
"Gender",
"]",
"=",
"None",
",",
"reverse",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"if",
"gender",
"is",
"None",
":",
"gender",
"=",
"get_random_item",
"(",
"Gender",
",... | Generate a random full name.
:param reverse: Return reversed full name.
:param gender: Gender's enum object.
:return: Full name.
:Example:
Johann Wolfgang. | [
"Generate",
"a",
"random",
"full",
"name",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L136-L159 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.username | def username(self, template: Optional[str] = None) -> str:
"""Generate username by template.
Supported template placeholders: (U, l, d)
Supported separators: (-, ., _)
Template must contain at least one "U" or "l" placeholder.
If template is None one of the following template... | python | def username(self, template: Optional[str] = None) -> str:
"""Generate username by template.
Supported template placeholders: (U, l, d)
Supported separators: (-, ., _)
Template must contain at least one "U" or "l" placeholder.
If template is None one of the following template... | [
"def",
"username",
"(",
"self",
",",
"template",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"str",
":",
"MIN_DATE",
"=",
"1800",
"MAX_DATE",
"=",
"2070",
"DEFAULT_TEMPLATE",
"=",
"'l.d'",
"templates",
"=",
"(",
"'U_d'",
",",
"'U.d'",
","... | Generate username by template.
Supported template placeholders: (U, l, d)
Supported separators: (-, ., _)
Template must contain at least one "U" or "l" placeholder.
If template is None one of the following templates is used:
('U_d', 'U.d', 'U-d', 'UU-d', 'UU.d', 'UU_d',
... | [
"Generate",
"username",
"by",
"template",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L161-L211 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.password | def password(self, length: int = 8, hashed: bool = False) -> str:
"""Generate a password or hash of password.
:param length: Length of password.
:param hashed: MD5 hash.
:return: Password or hash of password.
:Example:
k6dv2odff9#4h
"""
text = ascii_... | python | def password(self, length: int = 8, hashed: bool = False) -> str:
"""Generate a password or hash of password.
:param length: Length of password.
:param hashed: MD5 hash.
:return: Password or hash of password.
:Example:
k6dv2odff9#4h
"""
text = ascii_... | [
"def",
"password",
"(",
"self",
",",
"length",
":",
"int",
"=",
"8",
",",
"hashed",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"text",
"=",
"ascii_letters",
"+",
"digits",
"+",
"punctuation",
"password",
"=",
"''",
".",
"join",
"(",
"[",
"se... | Generate a password or hash of password.
:param length: Length of password.
:param hashed: MD5 hash.
:return: Password or hash of password.
:Example:
k6dv2odff9#4h | [
"Generate",
"a",
"password",
"or",
"hash",
"of",
"password",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L213-L231 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.email | def email(self, domains: Union[tuple, list] = None) -> str:
"""Generate a random email.
:param domains: List of custom domains for emails.
:type domains: list or tuple
:return: Email address.
:Example:
foretime10@live.com
"""
if not domains:
... | python | def email(self, domains: Union[tuple, list] = None) -> str:
"""Generate a random email.
:param domains: List of custom domains for emails.
:type domains: list or tuple
:return: Email address.
:Example:
foretime10@live.com
"""
if not domains:
... | [
"def",
"email",
"(",
"self",
",",
"domains",
":",
"Union",
"[",
"tuple",
",",
"list",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"not",
"domains",
":",
"domains",
"=",
"EMAIL_DOMAINS",
"domain",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"... | Generate a random email.
:param domains: List of custom domains for emails.
:type domains: list or tuple
:return: Email address.
:Example:
foretime10@live.com | [
"Generate",
"a",
"random",
"email",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L233-L251 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.social_media_profile | def social_media_profile(self,
site: Optional[SocialNetwork] = None) -> str:
"""Generate profile for random social network.
:return: Profile in some network.
:Example:
http://facebook.com/some_user
"""
key = self._validate_enum(site, Soc... | python | def social_media_profile(self,
site: Optional[SocialNetwork] = None) -> str:
"""Generate profile for random social network.
:return: Profile in some network.
:Example:
http://facebook.com/some_user
"""
key = self._validate_enum(site, Soc... | [
"def",
"social_media_profile",
"(",
"self",
",",
"site",
":",
"Optional",
"[",
"SocialNetwork",
"]",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"site",
",",
"SocialNetwork",
")",
"website",
"=",
"SOCIAL_NETWORKS",
"... | Generate profile for random social network.
:return: Profile in some network.
:Example:
http://facebook.com/some_user | [
"Generate",
"profile",
"for",
"random",
"social",
"network",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L253-L265 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.gender | def gender(self, iso5218: bool = False,
symbol: bool = False) -> Union[str, int]:
"""Get a random gender.
Get a random title of gender, code for the representation
of human sexes is an international standard that defines a
representation of human sexes through a language-... | python | def gender(self, iso5218: bool = False,
symbol: bool = False) -> Union[str, int]:
"""Get a random gender.
Get a random title of gender, code for the representation
of human sexes is an international standard that defines a
representation of human sexes through a language-... | [
"def",
"gender",
"(",
"self",
",",
"iso5218",
":",
"bool",
"=",
"False",
",",
"symbol",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"str",
",",
"int",
"]",
":",
"if",
"iso5218",
":",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"[... | Get a random gender.
Get a random title of gender, code for the representation
of human sexes is an international standard that defines a
representation of human sexes through a language-neutral single-digit
code or symbol of gender.
:param iso5218:
Codes for the re... | [
"Get",
"a",
"random",
"gender",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L267-L291 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.weight | def weight(self, minimum: int = 38, maximum: int = 90) -> int:
"""Generate a random weight in Kg.
:param minimum: min value
:param maximum: max value
:return: Weight.
:Example:
48.
"""
weight = self.random.randint(minimum, maximum)
return wei... | python | def weight(self, minimum: int = 38, maximum: int = 90) -> int:
"""Generate a random weight in Kg.
:param minimum: min value
:param maximum: max value
:return: Weight.
:Example:
48.
"""
weight = self.random.randint(minimum, maximum)
return wei... | [
"def",
"weight",
"(",
"self",
",",
"minimum",
":",
"int",
"=",
"38",
",",
"maximum",
":",
"int",
"=",
"90",
")",
"->",
"int",
":",
"weight",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"minimum",
",",
"maximum",
")",
"return",
"weight"
] | Generate a random weight in Kg.
:param minimum: min value
:param maximum: max value
:return: Weight.
:Example:
48. | [
"Generate",
"a",
"random",
"weight",
"in",
"Kg",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L306-L317 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.occupation | def occupation(self) -> str:
"""Get a random job.
:return: The name of job.
:Example:
Programmer.
"""
jobs = self._data['occupation']
return self.random.choice(jobs) | python | def occupation(self) -> str:
"""Get a random job.
:return: The name of job.
:Example:
Programmer.
"""
jobs = self._data['occupation']
return self.random.choice(jobs) | [
"def",
"occupation",
"(",
"self",
")",
"->",
"str",
":",
"jobs",
"=",
"self",
".",
"_data",
"[",
"'occupation'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"jobs",
")"
] | Get a random job.
:return: The name of job.
:Example:
Programmer. | [
"Get",
"a",
"random",
"job",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L344-L353 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.political_views | def political_views(self) -> str:
"""Get a random political views.
:return: Political views.
:Example:
Liberal.
"""
views = self._data['political_views']
return self.random.choice(views) | python | def political_views(self) -> str:
"""Get a random political views.
:return: Political views.
:Example:
Liberal.
"""
views = self._data['political_views']
return self.random.choice(views) | [
"def",
"political_views",
"(",
"self",
")",
"->",
"str",
":",
"views",
"=",
"self",
".",
"_data",
"[",
"'political_views'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"views",
")"
] | Get a random political views.
:return: Political views.
:Example:
Liberal. | [
"Get",
"a",
"random",
"political",
"views",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L355-L364 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.worldview | def worldview(self) -> str:
"""Get a random worldview.
:return: Worldview.
:Example:
Pantheism.
"""
views = self._data['worldview']
return self.random.choice(views) | python | def worldview(self) -> str:
"""Get a random worldview.
:return: Worldview.
:Example:
Pantheism.
"""
views = self._data['worldview']
return self.random.choice(views) | [
"def",
"worldview",
"(",
"self",
")",
"->",
"str",
":",
"views",
"=",
"self",
".",
"_data",
"[",
"'worldview'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"views",
")"
] | Get a random worldview.
:return: Worldview.
:Example:
Pantheism. | [
"Get",
"a",
"random",
"worldview",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L366-L375 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.views_on | def views_on(self) -> str:
"""Get a random views on.
:return: Views on.
:Example:
Negative.
"""
views = self._data['views_on']
return self.random.choice(views) | python | def views_on(self) -> str:
"""Get a random views on.
:return: Views on.
:Example:
Negative.
"""
views = self._data['views_on']
return self.random.choice(views) | [
"def",
"views_on",
"(",
"self",
")",
"->",
"str",
":",
"views",
"=",
"self",
".",
"_data",
"[",
"'views_on'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"views",
")"
] | Get a random views on.
:return: Views on.
:Example:
Negative. | [
"Get",
"a",
"random",
"views",
"on",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L377-L386 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.nationality | def nationality(self, gender: Optional[Gender] = None) -> str:
"""Get a random nationality.
:param gender: Gender.
:return: Nationality.
:Example:
Russian
"""
nationalities = self._data['nationality']
# Separated by gender
if isinstance(nati... | python | def nationality(self, gender: Optional[Gender] = None) -> str:
"""Get a random nationality.
:param gender: Gender.
:return: Nationality.
:Example:
Russian
"""
nationalities = self._data['nationality']
# Separated by gender
if isinstance(nati... | [
"def",
"nationality",
"(",
"self",
",",
"gender",
":",
"Optional",
"[",
"Gender",
"]",
"=",
"None",
")",
"->",
"str",
":",
"nationalities",
"=",
"self",
".",
"_data",
"[",
"'nationality'",
"]",
"if",
"isinstance",
"(",
"nationalities",
",",
"dict",
")",
... | Get a random nationality.
:param gender: Gender.
:return: Nationality.
:Example:
Russian | [
"Get",
"a",
"random",
"nationality",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L388-L404 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.university | def university(self) -> str:
"""Get a random university.
:return: University name.
:Example:
MIT.
"""
universities = self._data['university']
return self.random.choice(universities) | python | def university(self) -> str:
"""Get a random university.
:return: University name.
:Example:
MIT.
"""
universities = self._data['university']
return self.random.choice(universities) | [
"def",
"university",
"(",
"self",
")",
"->",
"str",
":",
"universities",
"=",
"self",
".",
"_data",
"[",
"'university'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"universities",
")"
] | Get a random university.
:return: University name.
:Example:
MIT. | [
"Get",
"a",
"random",
"university",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L406-L415 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.academic_degree | def academic_degree(self) -> str:
"""Get a random academic degree.
:return: Degree.
:Example:
Bachelor.
"""
degrees = self._data['academic_degree']
return self.random.choice(degrees) | python | def academic_degree(self) -> str:
"""Get a random academic degree.
:return: Degree.
:Example:
Bachelor.
"""
degrees = self._data['academic_degree']
return self.random.choice(degrees) | [
"def",
"academic_degree",
"(",
"self",
")",
"->",
"str",
":",
"degrees",
"=",
"self",
".",
"_data",
"[",
"'academic_degree'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"degrees",
")"
] | Get a random academic degree.
:return: Degree.
:Example:
Bachelor. | [
"Get",
"a",
"random",
"academic",
"degree",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L417-L426 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.language | def language(self) -> str:
"""Get a random language.
:return: Random language.
:Example:
Irish.
"""
languages = self._data['language']
return self.random.choice(languages) | python | def language(self) -> str:
"""Get a random language.
:return: Random language.
:Example:
Irish.
"""
languages = self._data['language']
return self.random.choice(languages) | [
"def",
"language",
"(",
"self",
")",
"->",
"str",
":",
"languages",
"=",
"self",
".",
"_data",
"[",
"'language'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"languages",
")"
] | Get a random language.
:return: Random language.
:Example:
Irish. | [
"Get",
"a",
"random",
"language",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L428-L437 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.telephone | def telephone(self, mask: str = '', placeholder: str = '#') -> str:
"""Generate a random phone number.
:param mask: Mask for formatting number.
:param placeholder: A placeholder for a mask (default is #).
:return: Phone number.
:Example:
+7-(963)-409-11-22.
... | python | def telephone(self, mask: str = '', placeholder: str = '#') -> str:
"""Generate a random phone number.
:param mask: Mask for formatting number.
:param placeholder: A placeholder for a mask (default is #).
:return: Phone number.
:Example:
+7-(963)-409-11-22.
... | [
"def",
"telephone",
"(",
"self",
",",
"mask",
":",
"str",
"=",
"''",
",",
"placeholder",
":",
"str",
"=",
"'#'",
")",
"->",
"str",
":",
"if",
"not",
"mask",
":",
"code",
"=",
"self",
".",
"random",
".",
"choice",
"(",
"CALLING_CODES",
")",
"default... | Generate a random phone number.
:param mask: Mask for formatting number.
:param placeholder: A placeholder for a mask (default is #).
:return: Phone number.
:Example:
+7-(963)-409-11-22. | [
"Generate",
"a",
"random",
"phone",
"number",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L439-L455 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.avatar | def avatar(self, size: int = 256) -> str:
"""Generate a random avatar..
:param size: Size of avatar.
:return: Link to avatar.
"""
url = 'https://api.adorable.io/avatars/{0}/{1}.png'
return url.format(size, self.password(hashed=True)) | python | def avatar(self, size: int = 256) -> str:
"""Generate a random avatar..
:param size: Size of avatar.
:return: Link to avatar.
"""
url = 'https://api.adorable.io/avatars/{0}/{1}.png'
return url.format(size, self.password(hashed=True)) | [
"def",
"avatar",
"(",
"self",
",",
"size",
":",
"int",
"=",
"256",
")",
"->",
"str",
":",
"url",
"=",
"'https://api.adorable.io/avatars/{0}/{1}.png'",
"return",
"url",
".",
"format",
"(",
"size",
",",
"self",
".",
"password",
"(",
"hashed",
"=",
"True",
... | Generate a random avatar..
:param size: Size of avatar.
:return: Link to avatar. | [
"Generate",
"a",
"random",
"avatar",
".."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L457-L464 | train |
lk-geimfari/mimesis | mimesis/providers/person.py | Person.identifier | def identifier(self, mask: str = '##-##/##') -> str:
"""Generate a random identifier by mask.
With this method you can generate any identifiers that
you need. Simply select the mask that you need.
:param mask:
The mask. Here ``@`` is a placeholder for characters and ``#`` i... | python | def identifier(self, mask: str = '##-##/##') -> str:
"""Generate a random identifier by mask.
With this method you can generate any identifiers that
you need. Simply select the mask that you need.
:param mask:
The mask. Here ``@`` is a placeholder for characters and ``#`` i... | [
"def",
"identifier",
"(",
"self",
",",
"mask",
":",
"str",
"=",
"'##-##/##'",
")",
"->",
"str",
":",
"return",
"self",
".",
"random",
".",
"custom_code",
"(",
"mask",
"=",
"mask",
")"
] | Generate a random identifier by mask.
With this method you can generate any identifiers that
you need. Simply select the mask that you need.
:param mask:
The mask. Here ``@`` is a placeholder for characters and ``#`` is
placeholder for digits.
:return: An identi... | [
"Generate",
"a",
"random",
"identifier",
"by",
"mask",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L466-L480 | train |
lk-geimfari/mimesis | mimesis/providers/clothing.py | Clothing.custom_size | def custom_size(self, minimum: int = 40, maximum: int = 62) -> int:
"""Generate clothing size using custom format.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Clothing size.
"""
return self.random.randint(minimum, maximum) | python | def custom_size(self, minimum: int = 40, maximum: int = 62) -> int:
"""Generate clothing size using custom format.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Clothing size.
"""
return self.random.randint(minimum, maximum) | [
"def",
"custom_size",
"(",
"self",
",",
"minimum",
":",
"int",
"=",
"40",
",",
"maximum",
":",
"int",
"=",
"62",
")",
"->",
"int",
":",
"return",
"self",
".",
"random",
".",
"randint",
"(",
"minimum",
",",
"maximum",
")"
] | Generate clothing size using custom format.
:param minimum: Minimum value.
:param maximum: Maximum value.
:return: Clothing size. | [
"Generate",
"clothing",
"size",
"using",
"custom",
"format",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/clothing.py#L33-L40 | train |
lk-geimfari/mimesis | mimesis/shortcuts.py | luhn_checksum | def luhn_checksum(num: str) -> str:
"""Calculate a checksum for num using the Luhn algorithm.
:param num: The number to calculate a checksum for as a string.
:return: Checksum for number.
"""
check = 0
for i, s in enumerate(reversed(num)):
sx = int(s)
sx = sx * 2 if i % 2 == 0 e... | python | def luhn_checksum(num: str) -> str:
"""Calculate a checksum for num using the Luhn algorithm.
:param num: The number to calculate a checksum for as a string.
:return: Checksum for number.
"""
check = 0
for i, s in enumerate(reversed(num)):
sx = int(s)
sx = sx * 2 if i % 2 == 0 e... | [
"def",
"luhn_checksum",
"(",
"num",
":",
"str",
")",
"->",
"str",
":",
"check",
"=",
"0",
"for",
"i",
",",
"s",
"in",
"enumerate",
"(",
"reversed",
"(",
"num",
")",
")",
":",
"sx",
"=",
"int",
"(",
"s",
")",
"sx",
"=",
"sx",
"*",
"2",
"if",
... | Calculate a checksum for num using the Luhn algorithm.
:param num: The number to calculate a checksum for as a string.
:return: Checksum for number. | [
"Calculate",
"a",
"checksum",
"for",
"num",
"using",
"the",
"Luhn",
"algorithm",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/shortcuts.py#L14-L26 | train |
lk-geimfari/mimesis | mimesis/shortcuts.py | download_image | def download_image(url: str = '', save_path: str = '',
unverified_ctx: bool = False) -> Union[None, str]:
"""Download image and save in current directory on local machine.
:param url: URL to image.
:param save_path: Saving path.
:param unverified_ctx: Create unverified context.
:... | python | def download_image(url: str = '', save_path: str = '',
unverified_ctx: bool = False) -> Union[None, str]:
"""Download image and save in current directory on local machine.
:param url: URL to image.
:param save_path: Saving path.
:param unverified_ctx: Create unverified context.
:... | [
"def",
"download_image",
"(",
"url",
":",
"str",
"=",
"''",
",",
"save_path",
":",
"str",
"=",
"''",
",",
"unverified_ctx",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"None",
",",
"str",
"]",
":",
"if",
"unverified_ctx",
":",
"ssl",
".",
"... | Download image and save in current directory on local machine.
:param url: URL to image.
:param save_path: Saving path.
:param unverified_ctx: Create unverified context.
:return: Path to downloaded image.
:rtype: str or None | [
"Download",
"image",
"and",
"save",
"in",
"current",
"directory",
"on",
"local",
"machine",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/shortcuts.py#L29-L53 | train |
lk-geimfari/mimesis | mimesis/builtins/pl.py | PolandSpecProvider.nip | 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)
... | python | 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)
... | [
"def",
"nip",
"(",
"self",
")",
"->",
"str",
":",
"nip_digits",
"=",
"[",
"int",
"(",
"d",
")",
"for",
"d",
"in",
"str",
"(",
"self",
".",
"random",
".",
"randint",
"(",
"101",
",",
"998",
")",
")",
"]",
"nip_digits",
"+=",
"[",
"self",
".",
... | Generate random valid 10-digit NIP.
:return: Valid 10-digit NIP | [
"Generate",
"random",
"valid",
"10",
"-",
"digit",
"NIP",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pl.py#L25-L40 | train |
lk-geimfari/mimesis | mimesis/builtins/pl.py | PolandSpecProvider.pesel | def pesel(self, birth_date: DateTime = None,
gender: Gender = None) -> str:
"""Generate random 11-digit PESEL.
:param birth_date: Initial birth date (optional)
:param gender: Gender of person
:return: Valid 11-digit PESEL
"""
date_object = birth_date
... | python | def pesel(self, birth_date: DateTime = None,
gender: Gender = None) -> str:
"""Generate random 11-digit PESEL.
:param birth_date: Initial birth date (optional)
:param gender: Gender of person
:return: Valid 11-digit PESEL
"""
date_object = birth_date
... | [
"def",
"pesel",
"(",
"self",
",",
"birth_date",
":",
"DateTime",
"=",
"None",
",",
"gender",
":",
"Gender",
"=",
"None",
")",
"->",
"str",
":",
"date_object",
"=",
"birth_date",
"if",
"not",
"date_object",
":",
"date_object",
"=",
"Datetime",
"(",
")",
... | Generate random 11-digit PESEL.
:param birth_date: Initial birth date (optional)
:param gender: Gender of person
:return: Valid 11-digit PESEL | [
"Generate",
"random",
"11",
"-",
"digit",
"PESEL",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pl.py#L42-L86 | train |
lk-geimfari/mimesis | mimesis/builtins/pl.py | PolandSpecProvider.regon | 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,... | python | 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,... | [
"def",
"regon",
"(",
"self",
")",
"->",
"str",
":",
"regon_coeffs",
"=",
"(",
"8",
",",
"9",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
")",
"regon_digits",
"=",
"[",
"self",
".",
"random",
".",
"randint",
"(",
"0",
",",
"9... | Generate random valid 9-digit REGON.
:return: Valid 9-digit REGON | [
"Generate",
"random",
"valid",
"9",
"-",
"digit",
"REGON",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pl.py#L88-L101 | train |
lk-geimfari/mimesis | mimesis/builtins/en.py | USASpecProvider.tracking_number | 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', '... | python | 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', '... | [
"def",
"tracking_number",
"(",
"self",
",",
"service",
":",
"str",
"=",
"'usps'",
")",
"->",
"str",
":",
"service",
"=",
"service",
".",
"lower",
"(",
")",
"if",
"service",
"not",
"in",
"(",
"'usps'",
",",
"'fedex'",
",",
"'ups'",
")",
":",
"raise",
... | Generate random tracking number.
Supported services: USPS, FedEx and UPS.
:param str service: Post service.
:return: Tracking number. | [
"Generate",
"random",
"tracking",
"number",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/en.py#L25-L52 | train |
lk-geimfari/mimesis | mimesis/builtins/en.py | USASpecProvider.ssn | 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... | python | 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... | [
"def",
"ssn",
"(",
"self",
")",
"->",
"str",
":",
"area",
"=",
"self",
".",
"random",
".",
"randint",
"(",
"1",
",",
"899",
")",
"if",
"area",
"==",
"666",
":",
"area",
"=",
"665",
"return",
"'{:03}-{:02}-{:04}'",
".",
"format",
"(",
"area",
",",
... | Generate a random, but valid SSN.
:returns: SSN.
:Example:
569-66-5801 | [
"Generate",
"a",
"random",
"but",
"valid",
"SSN",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/en.py#L54-L70 | train |
lk-geimfari/mimesis | mimesis/builtins/en.py | USASpecProvider.personality | def personality(self, category: str = 'mbti') -> Union[str, int]:
"""Generate a type of personality.
:param category: Category.
:return: Personality type.
:rtype: str or int
:Example:
ISFJ.
"""
mbtis = ('ISFJ', 'ISTJ', 'INFJ', 'INTJ',
... | python | def personality(self, category: str = 'mbti') -> Union[str, int]:
"""Generate a type of personality.
:param category: Category.
:return: Personality type.
:rtype: str or int
:Example:
ISFJ.
"""
mbtis = ('ISFJ', 'ISTJ', 'INFJ', 'INTJ',
... | [
"def",
"personality",
"(",
"self",
",",
"category",
":",
"str",
"=",
"'mbti'",
")",
"->",
"Union",
"[",
"str",
",",
"int",
"]",
":",
"mbtis",
"=",
"(",
"'ISFJ'",
",",
"'ISTJ'",
",",
"'INFJ'",
",",
"'INTJ'",
",",
"'ISTP'",
",",
"'ISFP'",
",",
"'INFP... | Generate a type of personality.
:param category: Category.
:return: Personality type.
:rtype: str or int
:Example:
ISFJ. | [
"Generate",
"a",
"type",
"of",
"personality",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/en.py#L72-L90 | train |
lk-geimfari/mimesis | mimesis/providers/units.py | UnitSystem.unit | def unit(self, name: Optional[UnitName] = None, symbol=False):
"""Get unit name.
:param name: Enum object UnitName.
:param symbol: Return only symbol
:return: Unit.
"""
result = self._validate_enum(item=name, enum=UnitName)
if symbol:
return result[1... | python | def unit(self, name: Optional[UnitName] = None, symbol=False):
"""Get unit name.
:param name: Enum object UnitName.
:param symbol: Return only symbol
:return: Unit.
"""
result = self._validate_enum(item=name, enum=UnitName)
if symbol:
return result[1... | [
"def",
"unit",
"(",
"self",
",",
"name",
":",
"Optional",
"[",
"UnitName",
"]",
"=",
"None",
",",
"symbol",
"=",
"False",
")",
":",
"result",
"=",
"self",
".",
"_validate_enum",
"(",
"item",
"=",
"name",
",",
"enum",
"=",
"UnitName",
")",
"if",
"sy... | Get unit name.
:param name: Enum object UnitName.
:param symbol: Return only symbol
:return: Unit. | [
"Get",
"unit",
"name",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/units.py#L22-L33 | train |
lk-geimfari/mimesis | mimesis/providers/units.py | UnitSystem.prefix | def prefix(self, sign: Optional[PrefixSign] = None,
symbol: bool = False) -> str:
"""Get a random prefix for the International System of Units.
:param sign: Sing of number.
:param symbol: Return symbol of prefix.
:return: Prefix for SI.
:raises NonEnumerableError:... | python | def prefix(self, sign: Optional[PrefixSign] = None,
symbol: bool = False) -> str:
"""Get a random prefix for the International System of Units.
:param sign: Sing of number.
:param symbol: Return symbol of prefix.
:return: Prefix for SI.
:raises NonEnumerableError:... | [
"def",
"prefix",
"(",
"self",
",",
"sign",
":",
"Optional",
"[",
"PrefixSign",
"]",
"=",
"None",
",",
"symbol",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"prefixes",
"=",
"SI_PREFIXES_SYM",
"if",
"symbol",
"else",
"SI_PREFIXES",
"key",
"=",
"se... | Get a random prefix for the International System of Units.
:param sign: Sing of number.
:param symbol: Return symbol of prefix.
:return: Prefix for SI.
:raises NonEnumerableError: if sign is not supported.
:Example:
mega | [
"Get",
"a",
"random",
"prefix",
"for",
"the",
"International",
"System",
"of",
"Units",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/units.py#L35-L51 | train |
lk-geimfari/mimesis | mimesis/builtins/nl.py | NetherlandsSpecProvider.bsn | 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:
mul... | python | 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:
mul... | [
"def",
"bsn",
"(",
"self",
")",
"->",
"str",
":",
"def",
"_is_valid_bsn",
"(",
"number",
":",
"str",
")",
"->",
"bool",
":",
"total",
"=",
"0",
"multiplier",
"=",
"9",
"for",
"char",
"in",
"number",
":",
"multiplier",
"=",
"-",
"multiplier",
"if",
... | Generate a random, but valid ``Burgerservicenummer``.
:returns: Random BSN.
:Example:
255159705 | [
"Generate",
"a",
"random",
"but",
"valid",
"Burgerservicenummer",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/nl.py#L23-L49 | train |
lk-geimfari/mimesis | mimesis/schema.py | Schema.create | def create(self, iterations: int = 1) -> List[JSON]:
"""Return filled schema.
Create a list of a filled schemas with elements in
an amount of **iterations**.
:param iterations: Amount of iterations.
:return: List of willed schemas.
"""
return [self.schema() for ... | python | def create(self, iterations: int = 1) -> List[JSON]:
"""Return filled schema.
Create a list of a filled schemas with elements in
an amount of **iterations**.
:param iterations: Amount of iterations.
:return: List of willed schemas.
"""
return [self.schema() for ... | [
"def",
"create",
"(",
"self",
",",
"iterations",
":",
"int",
"=",
"1",
")",
"->",
"List",
"[",
"JSON",
"]",
":",
"return",
"[",
"self",
".",
"schema",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"iterations",
")",
"]"
] | Return filled schema.
Create a list of a filled schemas with elements in
an amount of **iterations**.
:param iterations: Amount of iterations.
:return: List of willed schemas. | [
"Return",
"filled",
"schema",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/schema.py#L133-L142 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseProvider.reseed | def reseed(self, seed: Seed = None) -> None:
"""Reseed 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 rand... | python | def reseed(self, seed: Seed = None) -> None:
"""Reseed 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 rand... | [
"def",
"reseed",
"(",
"self",
",",
"seed",
":",
"Seed",
"=",
"None",
")",
"->",
"None",
":",
"if",
"self",
".",
"random",
"is",
"random",
":",
"self",
".",
"random",
"=",
"Random",
"(",
")",
"self",
".",
"seed",
"=",
"seed",
"self",
".",
"random"... | Reseed 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 ti... | [
"Reseed",
"the",
"internal",
"random",
"generator",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L35-L49 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseProvider._validate_enum | def _validate_enum(self, item: Any, enum: Any) -> Any:
"""Validate enum parameter of method in subclasses of BaseProvider.
:param item: Item of enum object.
:param enum: Enum object.
:return: Value of item.
:raises NonEnumerableError: if ``item`` not in ``enum``.
"""
... | python | def _validate_enum(self, item: Any, enum: Any) -> Any:
"""Validate enum parameter of method in subclasses of BaseProvider.
:param item: Item of enum object.
:param enum: Enum object.
:return: Value of item.
:raises NonEnumerableError: if ``item`` not in ``enum``.
"""
... | [
"def",
"_validate_enum",
"(",
"self",
",",
"item",
":",
"Any",
",",
"enum",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"item",
"is",
"None",
":",
"result",
"=",
"get_random_item",
"(",
"enum",
",",
"self",
".",
"random",
")",
"elif",
"item",
"and",
"... | Validate enum parameter of method in subclasses of BaseProvider.
:param item: Item of enum object.
:param enum: Enum object.
:return: Value of item.
:raises NonEnumerableError: if ``item`` not in ``enum``. | [
"Validate",
"enum",
"parameter",
"of",
"method",
"in",
"subclasses",
"of",
"BaseProvider",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L51-L66 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseDataProvider._setup_locale | def _setup_locale(self, locale: str = locales.DEFAULT_LOCALE) -> None:
"""Set up locale after pre-check.
:param str locale: Locale
:raises UnsupportedLocale: When locale is not supported.
:return: Nothing.
"""
if not locale:
locale = locales.DEFAULT_LOCALE
... | python | def _setup_locale(self, locale: str = locales.DEFAULT_LOCALE) -> None:
"""Set up locale after pre-check.
:param str locale: Locale
:raises UnsupportedLocale: When locale is not supported.
:return: Nothing.
"""
if not locale:
locale = locales.DEFAULT_LOCALE
... | [
"def",
"_setup_locale",
"(",
"self",
",",
"locale",
":",
"str",
"=",
"locales",
".",
"DEFAULT_LOCALE",
")",
"->",
"None",
":",
"if",
"not",
"locale",
":",
"locale",
"=",
"locales",
".",
"DEFAULT_LOCALE",
"locale",
"=",
"locale",
".",
"lower",
"(",
")",
... | Set up locale after pre-check.
:param str locale: Locale
:raises UnsupportedLocale: When locale is not supported.
:return: Nothing. | [
"Set",
"up",
"locale",
"after",
"pre",
"-",
"check",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L89-L103 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseDataProvider._update_dict | def _update_dict(self, initial: JSON, other: Mapping) -> JSON:
"""Recursively update a dictionary.
:param initial: Dict to update.
:param other: Dict to update from.
:return: Updated dict.
"""
for key, value in other.items():
if isinstance(value, collections.... | python | def _update_dict(self, initial: JSON, other: Mapping) -> JSON:
"""Recursively update a dictionary.
:param initial: Dict to update.
:param other: Dict to update from.
:return: Updated dict.
"""
for key, value in other.items():
if isinstance(value, collections.... | [
"def",
"_update_dict",
"(",
"self",
",",
"initial",
":",
"JSON",
",",
"other",
":",
"Mapping",
")",
"->",
"JSON",
":",
"for",
"key",
",",
"value",
"in",
"other",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"collections",
".",
... | Recursively update a dictionary.
:param initial: Dict to update.
:param other: Dict to update from.
:return: Updated dict. | [
"Recursively",
"update",
"a",
"dictionary",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L105-L118 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseDataProvider.pull | def pull(self, datafile: str = ''):
"""Pull the content from the JSON and memorize one.
Opens JSON file ``file`` in the folder ``data/locale``
and get content from the file and memorize ones using lru_cache.
:param datafile: The name of file.
:return: The content of the file.
... | python | def pull(self, datafile: str = ''):
"""Pull the content from the JSON and memorize one.
Opens JSON file ``file`` in the folder ``data/locale``
and get content from the file and memorize ones using lru_cache.
:param datafile: The name of file.
:return: The content of the file.
... | [
"def",
"pull",
"(",
"self",
",",
"datafile",
":",
"str",
"=",
"''",
")",
":",
"locale",
"=",
"self",
".",
"locale",
"data_dir",
"=",
"self",
".",
"_data_dir",
"if",
"not",
"datafile",
":",
"datafile",
"=",
"self",
".",
"_datafile",
"def",
"get_data",
... | Pull the content from the JSON and memorize one.
Opens JSON file ``file`` in the folder ``data/locale``
and get content from the file and memorize ones using lru_cache.
:param datafile: The name of file.
:return: The content of the file.
:raises UnsupportedLocale: if locale is ... | [
"Pull",
"the",
"content",
"from",
"the",
"JSON",
"and",
"memorize",
"one",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L121-L155 | train |
lk-geimfari/mimesis | mimesis/providers/base.py | BaseDataProvider._override_locale | def _override_locale(self, locale: str = locales.DEFAULT_LOCALE) -> None:
"""Overrides current locale with passed and pull data for new locale.
:param locale: Locale
:return: Nothing.
"""
self.locale = locale
self.pull.cache_clear()
self.pull() | python | def _override_locale(self, locale: str = locales.DEFAULT_LOCALE) -> None:
"""Overrides current locale with passed and pull data for new locale.
:param locale: Locale
:return: Nothing.
"""
self.locale = locale
self.pull.cache_clear()
self.pull() | [
"def",
"_override_locale",
"(",
"self",
",",
"locale",
":",
"str",
"=",
"locales",
".",
"DEFAULT_LOCALE",
")",
"->",
"None",
":",
"self",
".",
"locale",
"=",
"locale",
"self",
".",
"pull",
".",
"cache_clear",
"(",
")",
"self",
".",
"pull",
"(",
")"
] | Overrides current locale with passed and pull data for new locale.
:param locale: Locale
:return: Nothing. | [
"Overrides",
"current",
"locale",
"with",
"passed",
"and",
"pull",
"data",
"for",
"new",
"locale",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/base.py#L167-L175 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.street_number | def street_number(self, maximum: int = 1400) -> str:
"""Generate a random street number.
:param maximum: Maximum value.
:return: Street number.
"""
return str(self.random.randint(1, maximum)) | python | def street_number(self, maximum: int = 1400) -> str:
"""Generate a random street number.
:param maximum: Maximum value.
:return: Street number.
"""
return str(self.random.randint(1, maximum)) | [
"def",
"street_number",
"(",
"self",
",",
"maximum",
":",
"int",
"=",
"1400",
")",
"->",
"str",
":",
"return",
"str",
"(",
"self",
".",
"random",
".",
"randint",
"(",
"1",
",",
"maximum",
")",
")"
] | Generate a random street number.
:param maximum: Maximum value.
:return: Street number. | [
"Generate",
"a",
"random",
"street",
"number",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L66-L72 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.address | def address(self) -> str:
"""Generate a random full address.
:return: Full address.
"""
fmt = self._data['address_fmt']
st_num = self.street_number()
st_name = self.street_name()
if self.locale in SHORTENED_ADDRESS_FMT:
return fmt.format(
... | python | def address(self) -> str:
"""Generate a random full address.
:return: Full address.
"""
fmt = self._data['address_fmt']
st_num = self.street_number()
st_name = self.street_name()
if self.locale in SHORTENED_ADDRESS_FMT:
return fmt.format(
... | [
"def",
"address",
"(",
"self",
")",
"->",
"str",
":",
"fmt",
"=",
"self",
".",
"_data",
"[",
"'address_fmt'",
"]",
"st_num",
"=",
"self",
".",
"street_number",
"(",
")",
"st_name",
"=",
"self",
".",
"street_name",
"(",
")",
"if",
"self",
".",
"locale... | Generate a random full address.
:return: Full address. | [
"Generate",
"a",
"random",
"full",
"address",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L90-L119 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.state | def state(self, abbr: bool = False) -> str:
"""Get a random administrative district of country.
:param abbr: Return ISO 3166-2 code.
:return: Administrative district.
"""
return self.random.choice(
self._data['state']['abbr' if abbr else 'name']) | python | def state(self, abbr: bool = False) -> str:
"""Get a random administrative district of country.
:param abbr: Return ISO 3166-2 code.
:return: Administrative district.
"""
return self.random.choice(
self._data['state']['abbr' if abbr else 'name']) | [
"def",
"state",
"(",
"self",
",",
"abbr",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"self",
".",
"_data",
"[",
"'state'",
"]",
"[",
"'abbr'",
"if",
"abbr",
"else",
"'name'",
"]",
")"
] | Get a random administrative district of country.
:param abbr: Return ISO 3166-2 code.
:return: Administrative district. | [
"Get",
"a",
"random",
"administrative",
"district",
"of",
"country",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L121-L128 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.country_code | def country_code(self, fmt: Optional[CountryCode] = CountryCode.A2) -> str:
"""Get a random code of country.
Default format is :attr:`~enums.CountryCode.A2` (ISO 3166-1-alpha2),
you can change it by passing parameter ``fmt`` with enum object
:class:`~enums.CountryCode`.
:param ... | python | def country_code(self, fmt: Optional[CountryCode] = CountryCode.A2) -> str:
"""Get a random code of country.
Default format is :attr:`~enums.CountryCode.A2` (ISO 3166-1-alpha2),
you can change it by passing parameter ``fmt`` with enum object
:class:`~enums.CountryCode`.
:param ... | [
"def",
"country_code",
"(",
"self",
",",
"fmt",
":",
"Optional",
"[",
"CountryCode",
"]",
"=",
"CountryCode",
".",
"A2",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"fmt",
",",
"CountryCode",
")",
"return",
"self",
".",
"rand... | Get a random code of country.
Default format is :attr:`~enums.CountryCode.A2` (ISO 3166-1-alpha2),
you can change it by passing parameter ``fmt`` with enum object
:class:`~enums.CountryCode`.
:param fmt: Enum object CountryCode.
:return: Country code in selected format.
... | [
"Get",
"a",
"random",
"code",
"of",
"country",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L175-L187 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address._get_fs | def _get_fs(self, key: str, dms: bool = False) -> Union[str, float]:
"""Get float number.
:param key: Key (`lt` or `lg`).
:param dms: DMS format.
:return: Float number
"""
# Default range is a range of longitude.
rng = (-90, 90) if key == 'lt' else (-180, 180)
... | python | def _get_fs(self, key: str, dms: bool = False) -> Union[str, float]:
"""Get float number.
:param key: Key (`lt` or `lg`).
:param dms: DMS format.
:return: Float number
"""
# Default range is a range of longitude.
rng = (-90, 90) if key == 'lt' else (-180, 180)
... | [
"def",
"_get_fs",
"(",
"self",
",",
"key",
":",
"str",
",",
"dms",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"str",
",",
"float",
"]",
":",
"rng",
"=",
"(",
"-",
"90",
",",
"90",
")",
"if",
"key",
"==",
"'lt'",
"else",
"(",
"-",
"... | Get float number.
:param key: Key (`lt` or `lg`).
:param dms: DMS format.
:return: Float number | [
"Get",
"float",
"number",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L205-L219 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.latitude | def latitude(self, dms: bool = False) -> Union[str, float]:
"""Generate a random value of latitude.
:param dms: DMS format.
:return: Value of longitude.
"""
return self._get_fs('lt', dms) | python | def latitude(self, dms: bool = False) -> Union[str, float]:
"""Generate a random value of latitude.
:param dms: DMS format.
:return: Value of longitude.
"""
return self._get_fs('lt', dms) | [
"def",
"latitude",
"(",
"self",
",",
"dms",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"str",
",",
"float",
"]",
":",
"return",
"self",
".",
"_get_fs",
"(",
"'lt'",
",",
"dms",
")"
] | Generate a random value of latitude.
:param dms: DMS format.
:return: Value of longitude. | [
"Generate",
"a",
"random",
"value",
"of",
"latitude",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L221-L227 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.coordinates | def coordinates(self, dms: bool = False) -> dict:
"""Generate random geo coordinates.
:param dms: DMS format.
:return: Dict with coordinates.
"""
return {
'longitude': self._get_fs('lg', dms),
'latitude': self._get_fs('lt', dms),
} | python | def coordinates(self, dms: bool = False) -> dict:
"""Generate random geo coordinates.
:param dms: DMS format.
:return: Dict with coordinates.
"""
return {
'longitude': self._get_fs('lg', dms),
'latitude': self._get_fs('lt', dms),
} | [
"def",
"coordinates",
"(",
"self",
",",
"dms",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"return",
"{",
"'longitude'",
":",
"self",
".",
"_get_fs",
"(",
"'lg'",
",",
"dms",
")",
",",
"'latitude'",
":",
"self",
".",
"_get_fs",
"(",
"'lt'",
... | Generate random geo coordinates.
:param dms: DMS format.
:return: Dict with coordinates. | [
"Generate",
"random",
"geo",
"coordinates",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L237-L246 | train |
lk-geimfari/mimesis | mimesis/providers/address.py | Address.continent | def continent(self, code: bool = False) -> str:
"""Get a random continent name or continent code.
:param code: Return code of continent.
:return: Continent name.
"""
codes = CONTINENT_CODES if \
code else self._data['continent']
return self.random.choice(cod... | python | def continent(self, code: bool = False) -> str:
"""Get a random continent name or continent code.
:param code: Return code of continent.
:return: Continent name.
"""
codes = CONTINENT_CODES if \
code else self._data['continent']
return self.random.choice(cod... | [
"def",
"continent",
"(",
"self",
",",
"code",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"codes",
"=",
"CONTINENT_CODES",
"if",
"code",
"else",
"self",
".",
"_data",
"[",
"'continent'",
"]",
"return",
"self",
".",
"random",
".",
"choice",
"(",
... | Get a random continent name or continent code.
:param code: Return code of continent.
:return: Continent name. | [
"Get",
"a",
"random",
"continent",
"name",
"or",
"continent",
"code",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L248-L257 | train |
lk-geimfari/mimesis | mimesis/providers/business.py | Business.company_type | def company_type(self, abbr: bool = False) -> str:
"""Get a random type of business entity.
:param abbr: Abbreviated company type.
:return: Types of business entity.
"""
key = 'abbr' if abbr else 'title'
return self.random.choice(
self._data['company']['type'... | python | def company_type(self, abbr: bool = False) -> str:
"""Get a random type of business entity.
:param abbr: Abbreviated company type.
:return: Types of business entity.
"""
key = 'abbr' if abbr else 'title'
return self.random.choice(
self._data['company']['type'... | [
"def",
"company_type",
"(",
"self",
",",
"abbr",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"key",
"=",
"'abbr'",
"if",
"abbr",
"else",
"'title'",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"self",
".",
"_data",
"[",
"'company'",
"]"... | Get a random type of business entity.
:param abbr: Abbreviated company type.
:return: Types of business entity. | [
"Get",
"a",
"random",
"type",
"of",
"business",
"entity",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/business.py#L40-L49 | train |
lk-geimfari/mimesis | mimesis/providers/business.py | Business.currency_iso_code | def currency_iso_code(self, allow_random: bool = False) -> str:
"""Get code of the currency for current locale.
:param allow_random: Get a random ISO code.
:return: Currency code.
"""
if allow_random:
return self.random.choice(CURRENCY_ISO_CODES)
else:
... | python | def currency_iso_code(self, allow_random: bool = False) -> str:
"""Get code of the currency for current locale.
:param allow_random: Get a random ISO code.
:return: Currency code.
"""
if allow_random:
return self.random.choice(CURRENCY_ISO_CODES)
else:
... | [
"def",
"currency_iso_code",
"(",
"self",
",",
"allow_random",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"if",
"allow_random",
":",
"return",
"self",
".",
"random",
".",
"choice",
"(",
"CURRENCY_ISO_CODES",
")",
"else",
":",
"return",
"self",
".",
... | Get code of the currency for current locale.
:param allow_random: Get a random ISO code.
:return: Currency code. | [
"Get",
"code",
"of",
"the",
"currency",
"for",
"current",
"locale",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/business.py#L61-L70 | train |
lk-geimfari/mimesis | mimesis/providers/business.py | Business.price | def price(self, minimum: float = 10.00,
maximum: float = 1000.00) -> str:
"""Generate a random price.
:param minimum: Max value of price.
:param maximum: Min value of price.
:return: Price.
"""
price = self.random.uniform(minimum, maximum, precision=2)
... | python | def price(self, minimum: float = 10.00,
maximum: float = 1000.00) -> str:
"""Generate a random price.
:param minimum: Max value of price.
:param maximum: Min value of price.
:return: Price.
"""
price = self.random.uniform(minimum, maximum, precision=2)
... | [
"def",
"price",
"(",
"self",
",",
"minimum",
":",
"float",
"=",
"10.00",
",",
"maximum",
":",
"float",
"=",
"1000.00",
")",
"->",
"str",
":",
"price",
"=",
"self",
".",
"random",
".",
"uniform",
"(",
"minimum",
",",
"maximum",
",",
"precision",
"=",
... | Generate a random price.
:param minimum: Max value of price.
:param maximum: Min value of price.
:return: Price. | [
"Generate",
"a",
"random",
"price",
"."
] | 4b16ee7a8dba6281a904654a88dbb4b052869fc5 | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/business.py#L93-L102 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.