API¶
This part of the documentation covers all the public interfaces of Mimesis.
Random¶
Implements various helpers which are used in the various data providers.
This module contains custom Random()
class where implemented a lot of
methods which are not included in standard random.Random
,
but frequently used in this project.
- class mimesis.random.Random(x=None)[source]¶
Custom class for the possibility of extending.
The class is a subclass of the class
random.Random
from the module random of the standard library, which provides the custom methods.- custom_code(mask='@###', char='@', digit='#')[source]¶
Generate custom code using ascii uppercase and random integers.
Builtin Data Providers¶
BrazilSpecProvider¶
DenmarkSpecProvider¶
NetherlandsSpecProvider¶
RussiaSpecProvider¶
- class mimesis.builtins.RussiaSpecProvider(seed=<mimesis.types._MissingSeed object>)[source]¶
Class that provides special data for Russia (ru).
- passport_number()[source]¶
Generate random passport number.
- Return type
- Returns
Number.
- Example
560430
UkraineSpecProvider¶
USASpecProvider¶
PolandSpecProvider¶
Shortcuts¶
This module provides internal util functions.
Custom Exceptions¶
Custom exceptions which are used in Mimesis.
Base Providers¶
BaseProvider¶
- class mimesis.providers.BaseProvider(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
This is a base class for all providers.
- __init__(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
Initialize attributes.
Keep in mind, that locale-independent data providers will work only with keyword-only arguments since version 5.0.0.
BaseDataProvider¶
- class mimesis.providers.BaseDataProvider(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>)[source]¶
This is a base class for all data providers.
- __init__(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>)[source]¶
Initialize attributes for data providers.
Generic Providers¶
Generic¶
- class mimesis.Generic(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>)[source]¶
Class which contain all providers at one.
- __init__(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>)[source]¶
Initialize attributes lazily.
- add_provider(cls, **kwargs)[source]¶
Add a custom provider to Generic() object.
- Parameters
cls (
Type
[BaseProvider
]) – Custom provider.- Return type
- Returns
None
- Raises
TypeError – if cls is not class or is not a subclass of BaseProvider.
- add_providers(*providers)[source]¶
Add a lot of custom providers to Generic() object.
- Parameters
providers (
Type
[BaseProvider
]) – Custom providers.- Return type
- Returns
None
Locale-Dependent Providers¶
Address¶
- class mimesis.Address(*args, **kwargs)[source]¶
Class for generate fake address data.
This object provides all the data related to geographical location.
- calling_code()[source]¶
Get a random calling code of random country.
- Return type
- Returns
Calling code.
- country_code(code=CountryCode.A2)[source]¶
Get a random code of country.
Default format is
A2
(ISO 3166-1-alpha2), you can change it by passing parameterfmt
with enum objectCountryCode
.- Parameters
code (
Optional
[CountryCode
]) – Enum object CountryCode.- Return type
- Returns
Country code in selected format.
- Raises
KeyError – if fmt is not supported.
- zip_code()[source]¶
Generate a zip code.
An alias for
postal_code()
.- Return type
- Returns
Zip code.
Finance¶
- class mimesis.Finance(*args, **kwargs)[source]¶
Class for generating finance data.
- cryptocurrency_iso_code()[source]¶
Get symbol of random cryptocurrency.
- Return type
- Returns
Symbol of cryptocurrency.
- cryptocurrency_symbol()[source]¶
Get a cryptocurrency symbol.
- Return type
- Returns
Symbol of cryptocurrency.
- currency_symbol()[source]¶
Get a currency symbol for current locale.
- Return type
- Returns
Currency symbol.
Datetime¶
- class mimesis.Datetime(*args, **kwargs)[source]¶
Class for generating data related to the date and time.
- static bulk_create_datetimes(date_start, date_end, **kwargs)[source]¶
Bulk create datetime objects.
This method creates list of datetime objects from
date_start
todate_end
.You can use the following keyword arguments:
days
hours
minutes
seconds
microseconds
Warning
Empty
**kwargs
produces timedelta(0) which obviously cannot be used as step, so you have to pass valid**kwargs
fordatetime.timedelta
which will be used as a step by whichdate_start
will be incremented until it reachesdate_end
to avoid infinite loop which eventually leads toOverflowError
.See
datetime.timedelta
for more details.- Parameters
date_start (
datetime
) – Begin of the range.date_end (
datetime
) – End of the range.kwargs (
Any
) – Keyword arguments fordatetime.timedelta
- Return type
- Returns
List of datetime objects
- Raises
ValueError: When
date_start
/date_end
not passed, whendate_start
larger thandate_end
or when the given keywords for datetime.timedelta represent a non-positive timedelta.
- day_of_month()[source]¶
Generate a random day of month, from 1 to 31.
- Return type
- Returns
Random value from 1 to 31.
- formatted_datetime(fmt='', **kwargs)[source]¶
Generate datetime string in human readable format.
- Parameters
fmt (
str
) – Custom format (default is format for current locale)kwargs (
Any
) – Keyword arguments fordatetime()
- Return type
- Returns
Formatted datetime string.
- timezone(region=None)[source]¶
Get a random timezone.
- Parameters
region (
Optional
[TimezoneRegion
]) – Timezone region.- Return type
- Returns
Timezone.
Food¶
Person¶
- class mimesis.Person(*args, **kwargs)[source]¶
Class for generating personal data.
- __init__(*args, **kwargs)[source]¶
Initialize attributes.
- Parameters
locale – Current locale.
seed – Seed.
- academic_degree()[source]¶
Get a random academic degree.
- Return type
- Returns
Degree.
- Example
Bachelor.
- blood_type()[source]¶
Get a random blood type.
- Return type
- Returns
Blood type (blood group).
- Example
A+
- email(domains=None, unique=False)[source]¶
Generate a random email.
- Parameters
- Return type
- Returns
Email address.
- Raises
ValueError – if «unique» is True and the provider was seeded.
- Example
- gender(iso5218=False, symbol=False)[source]¶
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.
- identifier(mask='##-##/##')[source]¶
Generate a random identifier by mask.
With this method you can generate any identifiers that you need. Simply select the mask that you need.
- political_views()[source]¶
Get a random political views.
- Return type
- Returns
Political views.
- Example
Liberal.
- sex(*args, **kwargs)[source]¶
An alias for method self.gender().
See docstrings of method self.gender() for details.
- title(gender=None, title_type=None)[source]¶
Generate a random title for name.
You can generate random prefix or suffix for name using this method.
- username(mask=None, drange=(1800, 2100))[source]¶
Generate username by template.
You can create many different usernames using masks.
C stands for capitalized username.
U stands for uppercase username.
l stands for lowercase username.
d stands for digits in username.
You can also use symbols to separate the different parts of the username: . _ -
- Parameters
- Raises
ValueError – If template is not supported.
- Return type
- Returns
Username as string.
- Example:
>>> username(mask='C_C_d') Cotte_Article_1923 >>> username(mask='U.l.d') ELKINS.wolverine.2013 >>> username(mask='l_l_d', drange=(1900, 2021)) plasmic_blockader_1907
Science¶
- class mimesis.Science(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
Class for generating pseudo-scientific data.
- measure_unit(name=None, symbol=False)[source]¶
Get unit name from International System of Units.
- Parameters
name (
Optional
[MeasureUnit
]) – Enum object UnitName.symbol (
bool
) – Return only symbol
- Return type
- Returns
Unit.
- metric_prefix(sign=None, symbol=False)[source]¶
Get a random prefix for the International System of Units.
- Parameters
sign (
Optional
[MetricPrefixSign
]) – Sing of prefix (positive/negative).symbol (
bool
) – Return the symbol of the prefix.
- Return type
- Returns
Metric prefix for SI measure units.
- Raises
NonEnumerableError – if sign is not supported.
- Example
mega
Text¶
- class mimesis.Text(*args, **kwargs)[source]¶
Class for generating text data.
- __init__(*args, **kwargs)[source]¶
Initialize attributes.
- Parameters
locale – Current locale.
seed – Seed.
- answer()[source]¶
Get a random answer in current language.
- Return type
- Returns
An answer.
- Example
No
- level()[source]¶
Generate a random level of danger or something else.
- Return type
- Returns
Level.
- Example
critical.
- quote()[source]¶
Get a random quote.
- Return type
- Returns
Quote from movie.
- Example
“Bond… James Bond.”
Locale-Independent Providers¶
BinaryFile¶
- class mimesis.BinaryFile(*args, **kwargs)[source]¶
Class for generating binary data
- __init__(*args, **kwargs)[source]¶
Initialize attributes.
- Parameters
locale – Current locale.
seed – Seed.
- audio(*, file_type=AudioFile.MP3)[source]¶
Generates audio file of given format and returns it as bytes.
Note
This method accepts keyword-only arguments.
- compressed(*, file_type=CompressedFile.ZIP)[source]¶
Generates compressed file of given format and returns it as bytes.
Note
This method accepts keyword-only arguments.
- Parameters
file_type (
CompressedFile
) – File extension.- Return type
- Returns
File as a sequence of bytes.
- document(*, file_type=DocumentFile.PDF)[source]¶
Generates document of given format and returns it as bytes.
Note
This method accepts keyword-only arguments.
- Parameters
file_type (
DocumentFile
) – File extension.- Return type
- Returns
File as a sequence of bytes.
Code¶
- class mimesis.Code(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
A class, which provides methods for generating codes.
- ean(fmt=None)[source]¶
Generate EAN.
To change EAN format, pass parameter
code
with needed value of the enum objectEANFormat
.- Parameters
- Return type
- Returns
EAN.
- Raises
NonEnumerableError – if code is not enum EANFormat.
- isbn(fmt=None, locale=Locale.EN)[source]¶
Generate ISBN for current locale.
To change ISBN format, pass parameter
code
with needed value of the enum objectISBNFormat
- Parameters
fmt (
Optional
[ISBNFormat
]) – ISBN format.locale (
Locale
) – Locale code.
- Return type
- Returns
ISBN.
- Raises
NonEnumerableError – if code is not enum ISBNFormat.
Choice¶
Cryptographic¶
- class mimesis.Cryptographic(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
Class that provides cryptographic data.
- hash(algorithm=None)[source]¶
Generate random hash.
To change hashing algorithm, pass parameter
algorithm
with needed value of the enum objectAlgorithm
Warning
Seed is not applicable to this method, because of its cryptographic-safe nature.
- Parameters
- Return type
- Returns
Hash.
- Raises
NonEnumerableError – When algorithm is unsupported.
- mnemonic_phrase()[source]¶
Generate BIP-39-compatible mnemonic phrase.
- Return type
- Returns
Mnemonic phrase.
- static token_bytes(entropy=32)[source]¶
Generate byte string containing
entropy
bytes.The string has
entropy
random bytes, each byte converted to two hex digits.Warning
Seed is not applicable to this method, because of its cryptographic-safe nature.
- static token_hex(entropy=32)[source]¶
Return a random text string, in hexadecimal.
The string has entropy random bytes, each byte converted to two hex digits. If entropy is
None
or not supplied, a reasonable default is used.Warning
Seed is not applicable to this method, because of its cryptographic-safe nature.
Development¶
- class mimesis.Development(*args, **kwargs)[source]¶
Class for getting fake data for Developers.
- __init__(*args, **kwargs)[source]¶
Initialize attributes.
Keep in mind, that locale-independent data providers will work only with keyword-only arguments since version 5.0.0.
- Parameters
seed – Seed for random. When set to None the current system time is used.
- os()[source]¶
Get a random operating system or distributive name.
- Return type
- Returns
The name of OS.
- Example
Gentoo
- programming_language()[source]¶
Get a random programming language from the list.
- Return type
- Returns
Programming language.
- Example
Erlang.
File¶
- class mimesis.File(*args, **kwargs)[source]¶
Class for generate data related to files.
Hardware¶
- class mimesis.Hardware(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
Class for generate data related to hardware.
- cpu_codename()[source]¶
Get a random CPU code name.
- Return type
- Returns
CPU code name.
- Example
Cannonlake.
- cpu_frequency()[source]¶
Get a random frequency of CPU.
- Return type
- Returns
Frequency of CPU.
- Example
4.0 GHz.
- generation()[source]¶
Get a random generation.
- Return type
- Returns
Generation of something.
- Example
6th Generation.
- graphics()[source]¶
Get a random graphics.
- Return type
- Returns
Graphics.
- Example
Intel® Iris™ Pro Graphics 6200.
- phone_model()[source]¶
Get a random phone model.
- Return type
- Returns
Phone model.
- Example
Nokia Lumia 920.
- resolution()[source]¶
Get a random screen resolution.
- Return type
- Returns
Resolution of screen.
- Example
1280x720.
Internet¶
- class mimesis.Internet(*args, **kwargs)[source]¶
Class for generating data related to the internet.
- content_type(mime_type=None)[source]¶
Get a random HTTP content type.
- Return type
- Returns
Content type.
- Example
Content-Type: application/json
- hashtags(quantity=4)[source]¶
Generate a list of hashtags.
- Parameters
quantity (
int
) – The quantity of hashtags.- Return type
- Returns
The list of hashtags.
- Raises
NonEnumerableError – if category is not in Hashtag.
- Example
[‘#love’, ‘#sky’, ‘#nice’]
- http_request_headers()[source]¶
Generates a random HTTP request headers.
The following headers are included:
Referer
Authorization
Cookie
User-Agent
X-CSRF-Token
Content-Type
Content-Length
Connection
Cache-Control
Accept
Host
Accept-Language
- http_response_headers()[source]¶
Generate a random HTTP response headers.
The following headers are included:
Allow
Age
Server
Content-Type
X-Request-ID
Content-Language
Content-Location
Set-Cookie
Upgrade-Insecure-Requests
X-Content-Type-Options
X-XSS-Protection
Connection
X-Frame-Options
Content-Encoding
Cross-Origin-Opener-Policy
Cross-Origin-Resource-Policy
Strict-Transport-Security
- http_status_code()[source]¶
Get a random HTTP status code.
- Return type
- Returns
HTTP status.
- Example
200
- http_status_message()[source]¶
Get a random HTTP status message.
- Return type
- Returns
HTTP status message.
- Example
200 OK
- ip_v4_object()[source]¶
Generate random
ipaddress.IPv4Address
object.- Return type
- Returns
ipaddress.IPv4Address
object.
- ip_v6()[source]¶
Generate a random IPv6 address as string.
- Return type
- Returns
IPv6 address string.
- Example
2001:c244:cf9d:1fb1:c56d:f52c:8a04:94f3
- ip_v6_object()[source]¶
Generate random
ipaddress.IPv6Address
object.- Return type
- Returns
ipaddress.IPv6Address
object.
- mac_address()[source]¶
Generate a random MAC address.
- Return type
- Returns
Random MAC address.
- Example
00:16:3e:25:e7:f1
- port(port_range=PortRange.ALL)[source]¶
Generate random port.
- Parameters
port_range (
PortRange
) – PortRange enum object.- Return type
- Returns
Port number.
- Raises
NonEnumerableError – if port_range is not in PortRange.
- Example
8080
- static stock_image_url(width=1920, height=1080, keywords=None)[source]¶
Generate a random stock image URL hosted on Unsplash.
See «Random search term» on https://source.unsplash.com/ for more details.
- tld(*args, **kwargs)[source]¶
Generates random top level domain.
An alias for
top_level_domain()
- Return type
- top_level_domain(tld_type=TLDType.CCTLD)[source]¶
Generates random top level domain.
- Parameters
tld_type (
TLDType
) – Enum objectenums.TLDType
- Return type
- Returns
Top level domain.
- Raises
NonEnumerableError – if tld_type not in
enums.TLDType
.
- uri(scheme=URLScheme.HTTPS, tld_type=None, subdomains=None, query_params_count=None)[source]¶
Generate a random URI.
Numeric¶
- class mimesis.Numeric(*args, **kwargs)[source]¶
A provider for generating numeric data.
- __init__(*args, **kwargs)[source]¶
Initialize attributes.
Keep in mind, that locale-independent data providers will work only with keyword-only arguments since version 5.0.0.
- Parameters
seed – Seed for random. When set to None the current system time is used.
- complex_number(start_real=0.0, end_real=1.0, start_imag=0.0, end_imag=1.0, precision_real=15, precision_imag=15)[source]¶
Generate a random complex number.
- Parameters
start_real (
float
) – Start real range.end_real (
float
) – End real range.start_imag (
float
) – Start imaginary range.end_imag (
float
) – End imaginary range.precision_real (
int
) – Round a real part of number to a given precision.precision_imag (
int
) – Round the imaginary part of number to a given precision.
- Return type
- Returns
Complex numbers.
- complexes(start_real=0, end_real=1, start_imag=0, end_imag=1, precision_real=15, precision_imag=15, n=10)[source]¶
Generate a list of random complex numbers.
- Parameters
start_real (
float
) – Start real range.end_real (
float
) – End real range.start_imag (
float
) – Start imaginary range.end_imag (
float
) – End imaginary range.precision_real (
int
) – Round a real part of number to a given precision.precision_imag (
int
) – Round the imaginary part of number to a given precision.n (
int
) – Length of the list.
- Return type
- Returns
A list of random complex numbers.
- decimal_number(start=-1000.0, end=1000.0)[source]¶
Generate random decimal number.
- Parameters
- Return type
- Returns
decimal.Decimal
object.
- decimals(start=0.0, end=1000.0, n=10)[source]¶
Generate a decimal number as
decimal.Decimal
objects.
- float_number(start=-1000.0, end=1000.0, precision=15)[source]¶
Generate random float number in range [start, end].
- increment(accumulator=None)[source]¶
Generate incremental number.
Each call of this method returns an incrementing number (with the step of +1).
If accumulator passed then increments number associated with it.
- Example:
>>> self.increment() 1 >>> self.increment(accumulator="a") 1 >>> self.increment() 2 >>> self.increment(accumulator="a") 2 >>> self.increment(accumulator="b") 1 >>> self.increment(accumulator="a") 3
- integers(start=0, end=10, n=10)[source]¶
Generate a list of random integers.
Integers can be negative or positive numbers. .. note: You can use both positive and negative numbers.
Path¶
- class mimesis.Path(platform='linux', *args, **kwargs)[source]¶
Class that provides methods and property for generate paths.
- __init__(platform='linux', *args, **kwargs)[source]¶
Initialize attributes.
Supported platforms: ‘linux’, ‘darwin’, ‘win32’, ‘win64’.
- Parameters
platform (
str
) – Required platform type.
- dev_dir()[source]¶
Generate a random path to development directory.
- Return type
- Returns
Path.
- Example
/home/sherrell/Development/Python
Payment¶
- class mimesis.Payment(*args, **kwargs)[source]¶
Class that provides data related to payments.
- bitcoin_address()[source]¶
Generate a random bitcoin address.
Keep in mind that although it generates valid-looking addresses, it does not mean that they are actually valid.
- Return type
- Returns
Bitcoin address.
- Example
3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX
- credit_card_expiration_date(minimum=16, maximum=25)[source]¶
Generate a random expiration date for credit card.
- credit_card_network()[source]¶
Generate a random credit card network.
- Return type
- Returns
Credit card network
- Example
MasterCard
- credit_card_number(card_type=None)[source]¶
Generate a random credit card number.
- Parameters
card_type (
Optional
[CardType
]) – Issuing Network. Default is Visa.- Return type
- Returns
Credit card number.
- Raises
NotImplementedError – if card_type not supported.
- Example
4455 5299 1152 2450
- ethereum_address()[source]¶
Generate a random Ethereum address.
..note: The address will look like Ethereum address, but keep in mind that it is not the valid address.
- Return type
- Returns
Ethereum address.
- Example
0xe8ece9e6ff7dba52d4c07d37418036a89af9698d
Transport¶
- class mimesis.Transport(*, seed=<mimesis.types._MissingSeed object>, **kwargs)[source]¶
Class for generating data related to transports.
- airplane()[source]¶
Generate a dummy airplane model.
- Return type
- Returns
Airplane model.
- Example
Boeing 727.
Schema-based Generators¶
BaseField¶
- class mimesis.schema.BaseField(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>, providers=None)[source]¶
BaseField is a class for generating data by the name of the method.
Instance of this object takes any string which represents the name of any method of any supported data provider (
Generic
) and the**kwargs
of the method.See
perform
for more details.- perform(name=None, key=None, **kwargs)[source]¶
Performs the value of the field by its name.
It takes any string which represents the name of any method of any supported data provider and the
**kwargs
of this method.Note
Some data providers have methods with the same names and in such cases, you can explicitly define that the method belongs to data-provider
name='provider.name'
otherwise it will return the data from the first provider which has a methodname
.Allowed delimiters:
.
,:
,/
and space:provider.name
provider:name
provider/name
provider name
You can apply a key function to the result returned by the method, by passing a parameter key with a callable object which returns the final result.
- Parameters
- Return type
- Returns
Value which represented by method.
- Raises
ValueError – if provider not supported or if field not defined.
Field¶
- class mimesis.schema.Field(locale=Locale.EN, seed=<mimesis.types._MissingSeed object>, providers=None)[source]¶
Greedy field.
The field whcih evaluates immediately.
Warning
There is no case when you need to instance field in loops.
If you doing this:
for i in range(1000): field = Field()
You doing it wrong! It is a terrible idea that will lead to a memory leak.
Forewarned is forearmed.
- Example:
>>> _ = Field() >>> _('username') Dogtag_1836
Schema¶
- class mimesis.schema.Schema(schema)[source]¶
Class which return list of filled schemas.
- __mul__(other)[source]¶
Multiplies the schema by the number of iterations.
Schema multiplication is not lazy, so it will be performed immediately (in fact, you’re using
create()
under the hood).Warning
Multiplying the large and nested schema with a large number is obviously a stupid idea, so be reasonable on choosing a multiplier.
Usage:
schema = Schema(lambda: { 'email': _('username'), 'token': _('token_hex', key=lambda x: x[:8]) }) print(schema * 2) print(2 * schema)
Note
Keep in mind the priority and order of multipliers.
Instead of doing this:
>>> schema * 2 * 10
Where you evaluate the schema 2 times and then multiply the resulting list 10 times, you should do this:
>>> schema * (2 * 10) # Evaluates the schema 20 times.
In other words, the first multiplier evaluetes the schema:
>>> 1 * schema * 5
The result will be:
[ {"email": "efforts1859@test.com", "token": "f4a29754"}, {"email": "efforts1859@test.com", "token": "f4a29754"}, {"email": "efforts1859@test.com", "token": "f4a29754"}, {"email": "efforts1859@test.com", "token": "f4a29754"}, {"email": "efforts1859@test.com", "token": "f4a29754"}, ]
Because schema is evaluated first (1 * schema), and then the second multiplier is applied on the result of the first expression since.
- create(iterations=1)[source]¶
Creates a list of a fulfilled schemas.
Note
This method evaluates immediately, so be careful on creating large datasets otherwise you’re risking running out of memory.
If you need a lazy version of this method, see
iterator()
.
- loop()[source]¶
Fulfills a schema infinitely in a lazy way.
This method can be useful when you have some dynamic conditions in depend on which the generation must be interrupted.
Since data mimesis provides are limited, frequent calls of this method can cause data duplication.
Before using this method, ask yourself: Do I really need this? In most cases, the answer is: Nah,
iterator()
is enough.Do not use this method without interrupt conditions, otherwise, you’re risking running out of memory.
If you’re accepting all risks below and want to suppress the warnings then use
warnings.catch_warnings
- to_csv(file_path, iterations=100, **kwargs)[source]¶
Export a schema as a CSV file.
- Parameters
file_path (
str
) – File path.iterations (
int
) – The required number of rows.kwargs (
Any
) – The keyword arguments forcsv.DictWriter
class.
New in version 5.3.0
- Return type
- to_json(file_path, iterations=100, **kwargs)[source]¶
Export a schema as a JSON file.
- Parameters
file_path (
str
) – File path.iterations (
int
) – The required number of rows.kwargs (
Any
) – Extra keyword arguments forjson.dump()
class.
New in version 5.3.0
- Return type
- to_pickle(file_path, iterations=100, **kwargs)[source]¶
Export a schema as the pickled representation of the object to the file.
- Parameters
file_path (
str
) – File path.iterations (
int
) – The required number of rows.kwargs (
Any
) – Extra keyword arguments forpickle.dump()
class.
New in version 5.3.0
- Return type
Enums¶
Implements enums for a lot of methods.
Enums from this module are used in a lot of methods. You should always import enums from this module if you want behavior for the methods that differ from the default behavior.
You should never use your own enums in methods because in this case, there no guarantee that you will get the result which you actually expected.
Below you can see an example of usage enums in methods of data providers.
- class mimesis.enums.Algorithm(value)[source]¶
Provides algorithms which available.
An argument for
hash()
.- BLAKE2B = 'blake2b'¶
- BLAKE2S = 'blake2s'¶
- MD5 = 'md5'¶
- SHA1 = 'sha1'¶
- SHA224 = 'sha224'¶
- SHA256 = 'sha256'¶
- SHA384 = 'sha384'¶
- SHA512 = 'sha512'¶
- class mimesis.enums.AudioFile(value)[source]¶
Provides the audio file types.
An argument for
audio()
- AAC = 'aac'¶
- MP3 = 'mp3'¶
- class mimesis.enums.CardType(value)[source]¶
Provides credit card types.
An argument for
credit_card_number()
.- AMERICAN_EXPRESS = 'American Express'¶
- MASTER_CARD = 'MasterCard'¶
- VISA = 'Visa'¶
- class mimesis.enums.CompressedFile(value)[source]¶
Provides the compressed file types.
An argument for
compressed()
- GZIP = 'gz'¶
- ZIP = 'zip'¶
- class mimesis.enums.CountryCode(value)[source]¶
Provides types of country codes.
An argument for
country_code()
.- A2 = 'a2'¶
- A3 = 'a3'¶
- FIFA = 'fifa'¶
- IOC = 'ioc'¶
- NUMERIC = 'numeric'¶
- class mimesis.enums.DSNType(value)[source]¶
An enumeration.
- COUCHBASE = ('couchbase', 8092)¶
- MEMCACHED = ('memcached', 11211)¶
- MONGODB = ('mongodb', 27017)¶
- MYSQL = ('mysql', 3306)¶
- POSTGRES = ('postgres', 5432)¶
- RABBITMQ = ('rabbitmq', 5672)¶
- REDIS = ('redis', 6379)¶
- class mimesis.enums.DocumentFile(value)[source]¶
Provides the document file types.
An argument for
document()
- DOCX = 'docx'¶
- PDF = 'pdf'¶
- PPTX = 'pptx'¶
- XLSX = 'xlsx'¶
- class mimesis.enums.EANFormat(value)[source]¶
Provides formats of EAN.
An argument for
ean()
.- EAN13 = 'ean-13'¶
- EAN8 = 'ean-8'¶
- class mimesis.enums.FileType(value)[source]¶
Provides file types.
An argument for
extension()
andfile_name()
.- AUDIO = 'audio'¶
- COMPRESSED = 'compressed'¶
- DATA = 'data'¶
- EXECUTABLE = 'executable'¶
- IMAGE = 'image'¶
- SOURCE = 'source'¶
- TEXT = 'text'¶
- VIDEO = 'video'¶
- class mimesis.enums.Gender(value)[source]¶
Represents genders.
An argument for a lot of methods which are taking parameter
gender
.- FEMALE = 'female'¶
- MALE = 'male'¶
- class mimesis.enums.ISBNFormat(value)[source]¶
Provides formats of ISBN.
An argument for
isbn()
.- ISBN10 = 'isbn-10'¶
- ISBN13 = 'isbn-13'¶
- class mimesis.enums.ImageFile(value)[source]¶
Provides the image file types.
An argument for
image()
- GIF = 'gif'¶
- JPG = 'jpg'¶
- PNG = 'png'¶
- class mimesis.enums.Locale(value)[source]¶
This class provides access to the supported locales from one place.
An argument for all locale-depend providers.
- CS = 'cs'¶
- DA = 'da'¶
- DE = 'de'¶
- DEFAULT = 'en'¶
- DE_AT = 'de-at'¶
- DE_CH = 'de-ch'¶
- EL = 'el'¶
- EN = 'en'¶
- EN_AU = 'en-au'¶
- EN_CA = 'en-ca'¶
- EN_GB = 'en-gb'¶
- ES = 'es'¶
- ES_MX = 'es-mx'¶
- ET = 'et'¶
- FA = 'fa'¶
- FI = 'fi'¶
- FR = 'fr'¶
- HU = 'hu'¶
- IS = 'is'¶
- IT = 'it'¶
- JA = 'ja'¶
- KK = 'kk'¶
- KO = 'ko'¶
- NL = 'nl'¶
- NL_BE = 'nl-be'¶
- NO = 'no'¶
- PL = 'pl'¶
- PT = 'pt'¶
- PT_BR = 'pt-br'¶
- RU = 'ru'¶
- SK = 'sk'¶
- SV = 'sv'¶
- TR = 'tr'¶
- UK = 'uk'¶
- ZH = 'zh'¶
- class mimesis.enums.MeasureUnit(value)[source]¶
Provide unit names.
An argument for
measure_unit()
.- AMOUNT_OF_SUBSTANCE = ('mole', 'mol')¶
- ANGLE = ('radian', 'r')¶
- ELECTRICAL_CONDUCTANCE = ('siemens', 'S')¶
- ELECTRIC_CAPACITANCE = ('farad', 'F')¶
- ELECTRIC_CHARGE = ('coulomb', 'C')¶
- ELECTRIC_RESISTANCE = ('ohm', 'Ω')¶
- ENERGY = ('joule', 'J')¶
- FLUX = ('watt', 'W')¶
- FORCE = ('newton', 'N')¶
- FREQUENCY = ('hertz', 'Hz')¶
- INDUCTANCE = ('henry', 'H')¶
- INFORMATION = ('byte', 'b')¶
- MAGNETIC_FLUX = ('weber', 'Wb')¶
- MAGNETIC_FLUX_DENSITY = ('tesla', 'T')¶
- MASS = ('gram', 'gr')¶
- POWER = ('watt', 'W')¶
- PRESSURE = ('pascal', 'P')¶
- RADIOACTIVITY = ('becquerel', 'Bq')¶
- SOLID_ANGLE = ('steradian', '㏛')¶
- TEMPERATURE = ('Celsius', '°C')¶
- THERMODYNAMIC_TEMPERATURE = ('kelvin', 'K')¶
- VOLTAGE = ('volt', 'V')¶
- class mimesis.enums.MetricPrefixSign(value)[source]¶
Provides prefix signs.
An argument for
metric_prefix()`()
.- NEGATIVE = 'negative'¶
- POSITIVE = 'positive'¶
- class mimesis.enums.MimeType(value)[source]¶
Provides common mime types.
An argument for
mime_type()
.- APPLICATION = 'application'¶
- AUDIO = 'audio'¶
- IMAGE = 'image'¶
- MESSAGE = 'message'¶
- TEXT = 'text'¶
- VIDEO = 'video'¶
- class mimesis.enums.NumType(value)[source]¶
Provides the number types.
An argument for
matrix()
.- COMPLEX = 'complexes'¶
- DECIMAL = 'decimals'¶
- FLOAT = 'floats'¶
- INTEGER = 'integers'¶
- class mimesis.enums.PortRange(value)[source]¶
Represents port ranges.
An argument for
port()
.- ALL = (1, 65535)¶
- EPHEMERAL = (49152, 65535)¶
- REGISTERED = (1024, 49151)¶
- WELL_KNOWN = (1, 1023)¶
- class mimesis.enums.TLDType(value)[source]¶
Provides top level domain types.
An argument for a few methods which are taking parameter tld_type.
- CCTLD = 'cctld'¶
- GEOTLD = 'geotld'¶
- GTLD = 'gtld'¶
- STLD = 'stld'¶
- UTLD = 'utld'¶
- class mimesis.enums.TimezoneRegion(value)[source]¶
Provides regions of timezones.
An argument for
timezone()
.- AFRICA = 'Africa'¶
- AMERICA = 'America'¶
- ANTARCTICA = 'Antarctica'¶
- ARCTIC = 'Arctic'¶
- ASIA = 'Asia'¶
- ATLANTIC = 'Atlantic'¶
- AUSTRALIA = 'Australia'¶
- EUROPE = 'Europe'¶
- INDIAN = 'Indian'¶
- PACIFIC = 'Pacific'¶
- class mimesis.enums.TitleType(value)[source]¶
Represents title types.
An argument for
title()
.- ACADEMIC = 'academic'¶
- TYPICAL = 'typical'¶