INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Returns 10 character tax identification number, Polish: Numer identyfikacji podatkowej. https://pl.wikipedia.org/wiki/NIP
def company_vat(self): """ Returns 10 character tax identification number, Polish: Numer identyfikacji podatkowej. https://pl.wikipedia.org/wiki/NIP """ vat_digits = [] for _ in range(3): vat_digits.append(self.random_digit_not_null()) for _...
Returns the checksum of CPF digits. References to the algorithm: https://pt.wikipedia.org/wiki/Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo https://metacpan.org/source/MAMAWE/Algorithm-CheckDigits-v1.3.0/lib/Algorithm/CheckDigits/M11_004.pm
def checksum(digits): """ Returns the checksum of CPF digits. References to the algorithm: https://pt.wikipedia.org/wiki/Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo https://metacpan.org/source/MAMAWE/Algorithm-CheckDigits-v1.3.0/lib/Algorithm/CheckDigits/M11_004.pm """ s = 0 p = len(digit...
Brazilian RG, return plain numbers. Check: https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html
def rg(self): """ Brazilian RG, return plain numbers. Check: https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html """ digits = self.generator.random.sample(range(0, 9), 8) checksum = sum(i * digits[i - 2] for i in range(2, 10)) last_...
Generate the information required to create an ISBN-10 or ISBN-13.
def _body(self): """ Generate the information required to create an ISBN-10 or ISBN-13. """ ean = self.random_element(RULES.keys()) reg_group = self.random_element(RULES[ean].keys()) # Given the chosen ean/group, decide how long the # registrant/publication str...
Separate the registration from the publication in a given string. :param reg_pub: A string of digits representing a registration and publication. :param rules: A list of RegistrantRules which designate where to separate the values in the string. :returns: A (regis...
def _registrant_publication(reg_pub, rules): """ Separate the registration from the publication in a given string. :param reg_pub: A string of digits representing a registration and publication. :param rules: A list of RegistrantRules which designate where to sepa...
Ukrainian "Реєстраційний номер облікової картки платника податків" also known as "Ідентифікаційний номер фізичної особи".
def ssn(self): """ Ukrainian "Реєстраційний номер облікової картки платника податків" also known as "Ідентифікаційний номер фізичної особи". """ digits = [] # Number of days between 1899-12-31 and a birth date for digit in str((self.generator.date_object() - ...
:returns: A random state or territory abbreviation. :param include_territories: If True, territories will be included. If False, only states will be returned.
def state_abbr(self, include_territories=True): """ :returns: A random state or territory abbreviation. :param include_territories: If True, territories will be included. If False, only states will be returned. """ if include_territories: self.random_elem...
Generates a random string of upper and lowercase letters. :type min_chars: int :type max_chars: int :return: String. Random of random length between min and max characters.
def pystr(self, min_chars=None, max_chars=20): """ Generates a random string of upper and lowercase letters. :type min_chars: int :type max_chars: int :return: String. Random of random length between min and max characters. """ if min_chars is None: re...
Returns a dictionary. :nb_elements: number of elements for dictionary :variable_nb_elements: is use variable number of elements for dictionary :value_types: type of dictionary values
def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types): """ Returns a dictionary. :nb_elements: number of elements for dictionary :variable_nb_elements: is use variable number of elements for dictionary :value_types: type of dictionary values """ ...
See http://web.archive.org/web/20090930140939/http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm
def postcode(self): """ See http://web.archive.org/web/20090930140939/http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm """ postcode = '' pattern = self.random_element(self.postcode_formats) for placeholder in pattern: postcode += s...
:example '4703'
def postcode_in_state(self, state_abbr=None): """ :example '4703' """ if state_abbr is None: state_abbr = self.random_element(self.states_abbr) if state_abbr in self.states_abbr: postcode = "%d" % (self.generator.random.randint( ...
Returns a 9 digits Dutch SSN called "burgerservicenummer (BSN)". the Dutch "burgerservicenummer (BSN)" needs to pass the "11-proef", which is a check digit approach; this function essentially reverses the checksum steps to create a random valid BSN (which is 9 digits).
def ssn(self): """ Returns a 9 digits Dutch SSN called "burgerservicenummer (BSN)". the Dutch "burgerservicenummer (BSN)" needs to pass the "11-proef", which is a check digit approach; this function essentially reverses the checksum steps to create a random valid BSN (which is 9...
Calculate and return control digit for given list of digits based on ISO7064, MOD 11,10 standard.
def checksum(digits): """ Calculate and return control digit for given list of digits based on ISO7064, MOD 11,10 standard. """ remainder = 10 for digit in digits: remainder = (remainder + digit) % 10 if remainder == 0: remainder = 10 remainder = (remainder * ...
Calculate checksum of Estonian personal identity code. Checksum is calculated with "Modulo 11" method using level I or II scale: Level I scale: 1 2 3 4 5 6 7 8 9 1 Level II scale: 3 4 5 6 7 8 9 1 2 3 The digits of the personal code are multiplied by level I scale and summed; if remainder of modulo...
def checksum(digits): """Calculate checksum of Estonian personal identity code. Checksum is calculated with "Modulo 11" method using level I or II scale: Level I scale: 1 2 3 4 5 6 7 8 9 1 Level II scale: 3 4 5 6 7 8 9 1 2 3 The digits of the personal code are multiplied by level I scale and summe...
Returns 11 character Estonian personal identity code (isikukood, IK). Age of person is between 16 and 90 years, based on local computer date. This function assigns random sex to person. An Estonian Personal identification code consists of 11 digits, generally given without any whitespac...
def ssn(self, min_age=16, max_age=90): """ Returns 11 character Estonian personal identity code (isikukood, IK). Age of person is between 16 and 90 years, based on local computer date. This function assigns random sex to person. An Estonian Personal identification code consists ...
Optionally center the coord and pick a point within radius.
def coordinate(self, center=None, radius=0.001): """ Optionally center the coord and pick a point within radius. """ if center is None: return Decimal(str(self.generator.random.randint(-180000000, 180000000) / 1000000.0)).quantize( Decimal(".000001"), ...
Returns a random tuple specifying a coordinate set guaranteed to exist on land. Format is `(latitude, longitude, place name, two-letter country code, timezone)` Pass `coords_only` to return coordinates without metadata.
def location_on_land(self, coords_only=False): """Returns a random tuple specifying a coordinate set guaranteed to exist on land. Format is `(latitude, longitude, place name, two-letter country code, timezone)` Pass `coords_only` to return coordinates without metadata. """ place ...
Calculates and returns a control digit for given list of digits basing on PESEL standard.
def checksum(digits): """ Calculates and returns a control digit for given list of digits basing on PESEL standard. """ weights_for_check_digit = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7] check_digit = 0 for i in range(0, 10): check_digit += weights_for_check_digit[i] * digits[i] check_digit ...
Calculates and returns a month number basing on PESEL standard.
def calculate_month(birth_date): """ Calculates and returns a month number basing on PESEL standard. """ year = int(birth_date.strftime('%Y')) month = int(birth_date.strftime('%m')) + ((int(year / 100) - 14) % 5) * 20 return month
Returns 11 character Polish national identity code (Public Electronic Census System, Polish: Powszechny Elektroniczny System Ewidencji Ludności - PESEL). It has the form YYMMDDZZZXQ, where YYMMDD is the date of birth (with century encoded in month field), ZZZ is the personal identification numb...
def ssn(self): """ Returns 11 character Polish national identity code (Public Electronic Census System, Polish: Powszechny Elektroniczny System Ewidencji Ludności - PESEL). It has the form YYMMDDZZZXQ, where YYMMDD is the date of birth (with century encoded in month field), ZZZ ...
Returns a 13 digits Swiss SSN named AHV (German) or AVS (French and Italian) See: http://www.bsv.admin.ch/themen/ahv/00011/02185/
def ssn(self): """ Returns a 13 digits Swiss SSN named AHV (German) or AVS (French and Italian) See: http://www.bsv.admin.ch/themen/ahv/00011/02185/ """ def _checksum(digits): evensum = sum(digits[:-1:2]) oddsum ...
:return: Swiss UID number
def vat_id(self): """ :return: Swiss UID number """ def _checksum(digits): code = ['8', '6', '4', '2', '3', '5', '9', '7'] remainder = 11-(sum(map(lambda x, y: int(x) * int(y), code, digits)) % 11) if remainder == 10: return 0 ...
Returns a random integer between two values. :param min: lower bound value (inclusive; default=0) :param max: upper bound value (inclusive; default=9999) :param step: range step (default=1) :returns: random integer between min and max
def random_int(self, min=0, max=9999, step=1): """ Returns a random integer between two values. :param min: lower bound value (inclusive; default=0) :param max: upper bound value (inclusive; default=9999) :param step: range step (default=1) :returns: random integer betwe...
Returns a random digit/number between 0 and 9 or an empty string.
def random_digit_or_empty(self): """ Returns a random digit/number between 0 and 9 or an empty string. """ if self.generator.random.randint(0, 1): return self.generator.random.randint(0, 9) else: return ''
Returns a random non-zero digit/number between 1 and 9 or and empty string.
def random_digit_not_null_or_empty(self): """ Returns a random non-zero digit/number between 1 and 9 or and empty string. """ if self.generator.random.randint(0, 1): return self.generator.random.randint(1, 9) else: return ''
Returns a random number with 1 digit (default, when digits==None), a random number with 0 to given number of digits, or a random number with given number to given number of digits (when ``fix_len==True``). :param digits: maximum number of digits :param fix_len: should the number have f...
def random_number(self, digits=None, fix_len=False): """ Returns a random number with 1 digit (default, when digits==None), a random number with 0 to given number of digits, or a random number with given number to given number of digits (when ``fix_len==True``). :param digits: m...
Returns a random letter (between a-z and A-Z).
def random_letter(self): """Returns a random letter (between a-z and A-Z).""" return self.generator.random.choice( getattr(string, 'letters', string.ascii_letters))
Returns a random letter (between a-z and A-Z).
def random_letters(self, length=16): """Returns a random letter (between a-z and A-Z).""" return self.random_choices( getattr(string, 'letters', string.ascii_letters), length=length, )
Returns a list of random, non-unique elements from a passed object. If `elements` is a dictionary, the value will be used as a weighting element. For example:: random_element({"{{variable_1}}": 0.5, "{{variable_2}}": 0.2, "{{variable_3}}": 0.2, "{{variable_4}}": 0.1}) will have th...
def random_choices(self, elements=('a', 'b', 'c'), length=None): """ Returns a list of random, non-unique elements from a passed object. If `elements` is a dictionary, the value will be used as a weighting element. For example:: random_element({"{{variable_1}}": 0.5, "{{var...
Returns a list of random unique elements for the specified length. Multiple occurrences of the same value increase its probability to be in the output.
def random_sample(self, elements=('a', 'b', 'c'), length=None): """ Returns a list of random unique elements for the specified length. Multiple occurrences of the same value increase its probability to be in the output. """ return self.random_elements(elements, length, unique=Tru...
Returns a random value near number. :param number: value to which the result must be near :param le: result must be lower or equal to number :param ge: result must be greater or equal to number :returns: a random int near number
def randomize_nb_elements( self, number=10, le=False, ge=False, min=None, max=None): """ Returns a random value near number. :param number: value to which the result must be near :param le: result must be lower or e...
Replaces all placeholders in given text with randomized values, replacing: all hash sign ('#') occurrences with a random digit (from 0 to 9); all percentage sign ('%') occurrences with a random non-zero digit (from 1 to 9); all exclamation mark ('!') occurrences with a random digit (from...
def numerify(self, text='###'): """ Replaces all placeholders in given text with randomized values, replacing: all hash sign ('#') occurrences with a random digit (from 0 to 9); all percentage sign ('%') occurrences with a random non-zero digit (from 1 to 9); all exclamation mark...
Replaces all question mark ('?') occurrences with a random letter. :param text: string to be parsed :param letters: a set of letters to choose from. :returns: string with all letter placeholders filled in
def lexify(self, text='????', letters=string.ascii_letters): """ Replaces all question mark ('?') occurrences with a random letter. :param text: string to be parsed :param letters: a set of letters to choose from. :returns: string with all letter placeholders filled in "...
Replaces all placeholders with random numbers and letters. :param text: string to be parsed :returns: string with all numerical and letter placeholders filled in
def bothify(self, text='## ??', letters=string.ascii_letters): """ Replaces all placeholders with random numbers and letters. :param text: string to be parsed :returns: string with all numerical and letter placeholders filled in """ return self.lexify(self.numerify(text)...
Replaces all circumflex ('^') occurrences with a random hexadecimal character. :param text: string to be parsed :param upper: Format as uppercase hexadecimal :returns: string with all letter placeholders filled in
def hexify(self, text='^^^^', upper=False): """ Replaces all circumflex ('^') occurrences with a random hexadecimal character. :param text: string to be parsed :param upper: Format as uppercase hexadecimal :returns: string with all letter placeholders filled in "...
Calculate checksum of Norwegian personal identity code. Checksum is calculated with "Module 11" method using a scale. The digits of the personal code are multiplied by the corresponding number in the scale and summed; if remainder of module 11 of the sum is less than 10, checksum is the remainder. ...
def checksum(digits, scale): """ Calculate checksum of Norwegian personal identity code. Checksum is calculated with "Module 11" method using a scale. The digits of the personal code are multiplied by the corresponding number in the scale and summed; if remainder of module 11 of the sum is less...
Returns 11 character Norwegian personal identity code (Fødselsnummer). A Norwegian personal identity code consists of 11 digits, without any whitespace or other delimiters. The form is DDMMYYIIICC, where III is a serial number separating persons born oh the same date with different inte...
def ssn(self, dob=None, gender=None): """ Returns 11 character Norwegian personal identity code (Fødselsnummer). A Norwegian personal identity code consists of 11 digits, without any whitespace or other delimiters. The form is DDMMYYIIICC, where III is a serial number separating...
https://es.wikipedia.org/wiki/N%C3%BAmero_de_identidad_de_extranjero :return: a random Spanish NIE
def nie(self): """ https://es.wikipedia.org/wiki/N%C3%BAmero_de_identidad_de_extranjero :return: a random Spanish NIE """ first_chr = random.randrange(0, 3) doi_body = str(random.randrange(0, 10000000)).zfill(7) control = self._calculate_control_doi(str(first_chr...
https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal :return: NIF
def nif(self): """ https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal :return: NIF """ nie_body = str(random.randrange(0, 100000000)) # generate a number of a maximum of 8 characters long return nie_body.zfill(8) + self._calculate_control_doi(nie_bo...
https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal :return: a random Spanish CIF
def cif(self): """ https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal :return: a random Spanish CIF """ first_chr = random.choice('ABCDEFGHJNPQRSUVW') doi_body = str(random.randrange(0, 10000000)).zfill(7) cif = first_chr + doi_body r...
https://es.wikipedia.org/wiki/Identificador_de_objeto_digital :return: a random Spanish CIF or NIE or NIF
def doi(self): """ https://es.wikipedia.org/wiki/Identificador_de_objeto_digital :return: a random Spanish CIF or NIE or NIF """ return random.choice([self.cif, self.nie, self.nif])()
Calculate the letter that corresponds to the end of a CIF :param cif: calculated value so far needing a control character :return: CIF control character Code was converted from the minified js of: https://generadordni.es/
def _calculate_control_cif(cls, cif): """ Calculate the letter that corresponds to the end of a CIF :param cif: calculated value so far needing a control character :return: CIF control character Code was converted from the minified js of: https://generadordni.es/ """ ...
Returns 11 character Finnish personal identity code (Henkilötunnus, HETU, Swedish: Personbeteckning). This function assigns random gender to person. HETU consists of eleven characters of the form DDMMYYCZZZQ, where DDMMYY is the date of birth, C the century sign, ZZZ the individual ...
def ssn(self, min_age=0, max_age=105, artificial=False): """ Returns 11 character Finnish personal identity code (Henkilötunnus, HETU, Swedish: Personbeteckning). This function assigns random gender to person. HETU consists of eleven characters of the form DDMMYYCZZZQ, where ...
Returns the century code for a given year
def _get_century_code(year): """Returns the century code for a given year""" if 2000 <= year < 3000: separator = 'A' elif 1900 <= year < 2000: separator = '-' elif 1800 <= year < 1900: separator = '+' else: raise ValueError('Finnish...
Returns a 10 digit Swedish SSN, "Personnummer". It consists of 10 digits in the form YYMMDD-SSGQ, where YYMMDD is the date of birth, SSS is a serial number and Q is a control character (Luhn checksum). http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
def ssn(self, min_age=18, max_age=90): """ Returns a 10 digit Swedish SSN, "Personnummer". It consists of 10 digits in the form YYMMDD-SSGQ, where YYMMDD is the date of birth, SSS is a serial number and Q is a control character (Luhn checksum). http://en.wikipedia.org/w...
Generates a basic profile with personal informations
def simple_profile(self, sex=None): """ Generates a basic profile with personal informations """ SEX = ["F", "M"] if sex not in SEX: sex = self.random_element(SEX) if sex == 'F': name = self.generator.name_female() elif sex == 'M': ...
Generates a complete profile. If "fields" is not empty, only the fields in the list will be returned
def profile(self, fields=None, sex=None): """ Generates a complete profile. If "fields" is not empty, only the fields in the list will be returned """ if fields is None: fields = [] d = { "job": self.generator.job(), "company": self.ge...
:example 'John Doe'
def name(self): """ :example 'John Doe' """ pattern = self.random_element(self.formats) return self.generator.parse(pattern)
Generate a safe datetime from a datetime.date or datetime.datetime object.
def new_datetime(d): """ Generate a safe datetime from a datetime.date or datetime.datetime object. """ kw = [d.year, d.month, d.day] if isinstance(d, real_datetime): kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo]) return datetime(*kw)
:example 'Acme Ltd'
def company(self): """ :example 'Acme Ltd' """ pattern = self.random_element(self.formats) return self.generator.parse(pattern)
:example 'Robust full-range hub'
def catch_phrase(self): """ :example 'Robust full-range hub' """ result = [] for word_list in self.catch_phrase_words: result.append(self.random_element(word_list)) return " ".join(result)
:example 'integrate extensible convergence'
def bs(self): """ :example 'integrate extensible convergence' """ result = [] for word_list in self.bsWords: result.append(self.random_element(word_list)) return " ".join(result)
:param category: application|audio|image|message|model|multipart|text|video
def mime_type(self, category=None): """ :param category: application|audio|image|message|model|multipart|text|video """ category = category if category else self.random_element( list(self.mime_types.keys())) return self.random_element(self.mime_types[category])
:param category: audio|image|office|text|video :param extension: file extension
def file_name(self, category=None, extension=None): """ :param category: audio|image|office|text|video :param extension: file extension """ extension = extension if extension else self.file_extension(category) filename = self.generator.word() return '{0}.{1}'.form...
:param category: audio|image|office|text|video
def file_extension(self, category=None): """ :param category: audio|image|office|text|video """ category = category if category else self.random_element( list(self.file_extensions.keys())) return self.random_element(self.file_extensions[category])
:param category: audio|image|office|text|video :param extension: file extension :param depth: depth of the file (depth >= 0)
def file_path(self, depth=1, category=None, extension=None): """ :param category: audio|image|office|text|video :param extension: file extension :param depth: depth of the file (depth >= 0) """ file = self.file_name(category, extension) path = "/{0}".format(file) ...
:param prefix: sd|vd|xvd
def unix_device(self, prefix=None): """ :param prefix: sd|vd|xvd """ prefix = prefix or self.random_element(self.unix_device_prefixes) suffix = self.random_element(string.ascii_lowercase) path = '/dev/%s%s' % (prefix, suffix) return path
:param prefix: sd|vd|xvd
def unix_partition(self, prefix=None): """ :param prefix: sd|vd|xvd """ path = self.unix_device(prefix=prefix) path += str(self.random_digit()) return path
Generate a random United States Individual Taxpayer Identification Number (ITIN). An United States Individual Taxpayer Identification Number (ITIN) is a tax processing number issued by the Internal Revenue Service. It is a nine-digit number that always begins with the number 9 and has a...
def itin(self): """Generate a random United States Individual Taxpayer Identification Number (ITIN). An United States Individual Taxpayer Identification Number (ITIN) is a tax processing number issued by the Internal Revenue Service. It is a nine-digit number that always begins ...
Generate a random United States Employer Identification Number (EIN). An United States An Employer Identification Number (EIN) is also known as a Federal Tax Identification Number, and is used to identify a business entity. EINs follow a format of a two-digit prefix followed by a hy...
def ein(self): """Generate a random United States Employer Identification Number (EIN). An United States An Employer Identification Number (EIN) is also known as a Federal Tax Identification Number, and is used to identify a business entity. EINs follow a format of a two-dig...
Generate a random United States Taxpayer Identification Number of the specified type. If no type is specified, a US SSN is returned.
def ssn(self, taxpayer_identification_number_type=SSN_TYPE): """ Generate a random United States Taxpayer Identification Number of the specified type. If no type is specified, a US SSN is returned. """ if taxpayer_identification_number_type == self.ITIN_TYPE: return self.it...
:example 'a segurança de evoluir sem preocupação'
def catch_phrase(self): """ :example 'a segurança de evoluir sem preocupação' """ pattern = self.random_element(self.catch_phrase_formats) catch_phrase = self.generator.parse(pattern) catch_phrase = catch_phrase[0].upper() + catch_phrase[1:] return catch_phrase
Generates a IDE number (9 digits). http://www.bfs.admin.ch/bfs/portal/fr/index/themen/00/05/blank/03/02.html
def ide(self): """ Generates a IDE number (9 digits). http://www.bfs.admin.ch/bfs/portal/fr/index/themen/00/05/blank/03/02.html """ def _checksum(digits): factors = (5, 4, 3, 2, 7, 6, 5, 4) sum_ = 0 for i in range(len(digits)): ...
Get a timestamp between January 1, 1970 and now, unless passed explicit start_datetime or end_datetime values. :example 1061306726
def unix_time(self, end_datetime=None, start_datetime=None): """ Get a timestamp between January 1, 1970 and now, unless passed explicit start_datetime or end_datetime values. :example 1061306726 """ start_datetime = self._parse_start_datetime(start_datetime) end_...
Get a timedelta object
def time_delta(self, end_datetime=None): """ Get a timedelta object """ start_datetime = self._parse_start_datetime('now') end_datetime = self._parse_end_datetime(end_datetime) seconds = end_datetime - start_datetime ts = self.generator.random.randint(*sorted([0,...
Get a datetime object for a date between January 1, 1970 and now :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2005-08-16 20:39:21') :return datetime
def date_time(self, tzinfo=None, end_datetime=None): """ Get a datetime object for a date between January 1, 1970 and now :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2005-08-16 20:39:21') :return datetime """ # NOTE: On windows...
Get a datetime object for a date between January 1, 001 and now :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('1265-03-22 21:15:52') :return datetime
def date_time_ad(self, tzinfo=None, end_datetime=None, start_datetime=None): """ Get a datetime object for a date between January 1, 001 and now :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('1265-03-22 21:15:52') :return datetime """ ...
:param tzinfo: timezone, instance of datetime.tzinfo subclass :example '2003-10-21T16:05:52+0000'
def iso8601(self, tzinfo=None, end_datetime=None): """ :param tzinfo: timezone, instance of datetime.tzinfo subclass :example '2003-10-21T16:05:52+0000' """ return self.date_time(tzinfo, end_datetime=end_datetime).isoformat()
Get a date string between January 1, 1970 and now :param pattern format :example '2008-11-27'
def date(self, pattern='%Y-%m-%d', end_datetime=None): """ Get a date string between January 1, 1970 and now :param pattern format :example '2008-11-27' """ return self.date_time(end_datetime=end_datetime).strftime(pattern)
Get a time string (24h format by default) :param pattern format :example '15:02:34'
def time(self, pattern='%H:%M:%S', end_datetime=None): """ Get a time string (24h format by default) :param pattern format :example '15:02:34' """ return self.date_time( end_datetime=end_datetime).time().strftime(pattern)
Get a Date object based on a random date between two given dates. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to 30 years ago :param end_date Defaults to "today" :example Date('1999-02-02') :return Date
def date_between(self, start_date='-30y', end_date='today'): """ Get a Date object based on a random date between two given dates. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to 30 years ago :param end_date Defaults to "today" :...
Get a DateTime object based on a random date between two given dates. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to 30 years ago :param end_date Defaults to "now" :param tzinfo: timezone, instance of datetime.tzinfo subclass :example D...
def date_time_between(self, start_date='-30y', end_date='now', tzinfo=None): """ Get a DateTime object based on a random date between two given dates. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to 30 years ago :param end_date Defaults ...
Get a DateTime object based on a random date between 1 second form now and a given date. Accepts date strings that can be recognized by strtotime(). :param end_date Defaults to "+30d" :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('1999-02-02 11:...
def future_datetime(self, end_date='+30d', tzinfo=None): """ Get a DateTime object based on a random date between 1 second form now and a given date. Accepts date strings that can be recognized by strtotime(). :param end_date Defaults to "+30d" :param tzinfo: timezone, i...
Get a DateTime object based on a random date between a given date and 1 second ago. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to "-30d" :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('1999-02-02 11:42:...
def past_datetime(self, start_date='-30d', tzinfo=None): """ Get a DateTime object based on a random date between a given date and 1 second ago. Accepts date strings that can be recognized by strtotime(). :param start_date Defaults to "-30d" :param tzinfo: timezone, inst...
Takes two DateTime objects and returns a random datetime between the two given datetimes. Accepts DateTime objects. :param datetime_start: DateTime :param datetime_end: DateTime :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('1999-02-02 1...
def date_time_between_dates( self, datetime_start=None, datetime_end=None, tzinfo=None): """ Takes two DateTime objects and returns a random datetime between the two given datetimes. Accepts DateTime objects. :param datetime_start:...
Gets a DateTime object for the current century. :param before_now: include days in current century before today :param after_now: include days in current century after today :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2012-04-04 11:02:02') :r...
def date_time_this_century( self, before_now=True, after_now=False, tzinfo=None): """ Gets a DateTime object for the current century. :param before_now: include days in current century before today :param after_now: include days in current...
Gets a DateTime object for the decade year. :param before_now: include days in current decade before today :param after_now: include days in current decade after today :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2012-04-04 11:02:02') :return ...
def date_time_this_decade( self, before_now=True, after_now=False, tzinfo=None): """ Gets a DateTime object for the decade year. :param before_now: include days in current decade before today :param after_now: include days in current decad...
Gets a DateTime object for the current year. :param before_now: include days in current year before today :param after_now: include days in current year after today :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2012-04-04 11:02:02') :return Dat...
def date_time_this_year( self, before_now=True, after_now=False, tzinfo=None): """ Gets a DateTime object for the current year. :param before_now: include days in current year before today :param after_now: include days in current year aft...
Gets a DateTime object for the current month. :param before_now: include days in current month before today :param after_now: include days in current month after today :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2012-04-04 11:02:02') :return ...
def date_time_this_month( self, before_now=True, after_now=False, tzinfo=None): """ Gets a DateTime object for the current month. :param before_now: include days in current month before today :param after_now: include days in current month...
Gets a Date object for the current century. :param before_today: include days in current century before today :param after_today: include days in current century after today :example Date('2012-04-04') :return Date
def date_this_century(self, before_today=True, after_today=False): """ Gets a Date object for the current century. :param before_today: include days in current century before today :param after_today: include days in current century after today :example Date('2012-04-04') ...
Gets a Date object for the decade year. :param before_today: include days in current decade before today :param after_today: include days in current decade after today :example Date('2012-04-04') :return Date
def date_this_decade(self, before_today=True, after_today=False): """ Gets a Date object for the decade year. :param before_today: include days in current decade before today :param after_today: include days in current decade after today :example Date('2012-04-04') :retu...
Gets a Date object for the current year. :param before_today: include days in current year before today :param after_today: include days in current year after today :example Date('2012-04-04') :return Date
def date_this_year(self, before_today=True, after_today=False): """ Gets a Date object for the current year. :param before_today: include days in current year before today :param after_today: include days in current year after today :example Date('2012-04-04') :return Da...
Gets a Date object for the current month. :param before_today: include days in current month before today :param after_today: include days in current month after today :param tzinfo: timezone, instance of datetime.tzinfo subclass :example DateTime('2012-04-04 11:02:02') :return ...
def date_this_month(self, before_today=True, after_today=False): """ Gets a Date object for the current month. :param before_today: include days in current month before today :param after_today: include days in current month after today :param tzinfo: timezone, instance of datet...
Returns a generator yielding tuples of ``(<datetime>, <value>)``. The data points will start at ``start_date``, and be at every time interval specified by ``precision``. ``distrib`` is a callable that accepts ``<datetime>`` and returns ``<value>``
def time_series( self, start_date='-30d', end_date='now', precision=None, distrib=None, tzinfo=None): """ Returns a generator yielding tuples of ``(<datetime>, <value>)``. The data points will start at ``start_date``, and b...
Generate a random date of birth represented as a Date object, constrained by optional miminimum_age and maximum_age parameters. :param tzinfo Defaults to None. :param minimum_age Defaults to 0. :param maximum_age Defaults to 115. :example Date('1979-02-02') :ret...
def date_of_birth(self, tzinfo=None, minimum_age=0, maximum_age=115): """ Generate a random date of birth represented as a Date object, constrained by optional miminimum_age and maximum_age parameters. :param tzinfo Defaults to None. :param minimum_age Defaults to 0. ...
Adds two or more dicts together. Common keys will have their values added. For example:: >>> t1 = {'a':1, 'b':2} >>> t2 = {'b':1, 'c':3} >>> t3 = {'d':4} >>> add_dicts(t1, t2, t3) {'a': 1, 'c': 3, 'b': 3, 'd': 4}
def add_dicts(*args): """ Adds two or more dicts together. Common keys will have their values added. For example:: >>> t1 = {'a':1, 'b':2} >>> t2 = {'b':1, 'c':3} >>> t3 = {'d':4} >>> add_dicts(t1, t2, t3) {'a': 1, 'c': 3, 'b': 3, 'd': 4} """ counters = [...
Returns the provider's name of the credit card.
def credit_card_provider(self, card_type=None): """ Returns the provider's name of the credit card. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) return self._credit_card_type(card_type).name
Returns a valid credit card number.
def credit_card_number(self, card_type=None): """ Returns a valid credit card number. """ card = self._credit_card_type(card_type) prefix = self.random_element(card.prefixes) number = self._generate_number(self.numerify(prefix), card.length) return number
Returns a security code string.
def credit_card_security_code(self, card_type=None): """ Returns a security code string. """ sec_len = self._credit_card_type(card_type).security_code_length return self.numerify('#' * sec_len)
Returns a random credit card type instance.
def _credit_card_type(self, card_type=None): """ Returns a random credit card type instance. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) elif isinstance(card_type, CreditCard): return card_type return self.credit_card_t...
'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16
def _generate_number(self, prefix, length): """ 'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16 """ number = prefix # Generate random char digits number += '#' * (len...
Returns Finnish company Business Identity Code (y-tunnus). Format is 8 digits - e.g. FI99999999,[8] last digit is a check digit utilizing MOD 11-2. The first digit is zero for some old organizations. This function provides current codes starting with non-zero.
def company_business_id(self): """ Returns Finnish company Business Identity Code (y-tunnus). Format is 8 digits - e.g. FI99999999,[8] last digit is a check digit utilizing MOD 11-2. The first digit is zero for some old organizations. This function provides current codes starting...
Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string The first 6 digits represent the birthdate with (in order) year, month and day. The second group of 3 digits is represents a sequence number (order of birth). It is even for women and odd for men. For men the range...
def ssn(self): """ Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string The first 6 digits represent the birthdate with (in order) year, month and day. The second group of 3 digits is represents a sequence number (order of birth). It is even for women and odd...
:example 세종특별자치시 어진동 507
def land_address(self): """ :example 세종특별자치시 어진동 507 """ pattern = self.random_element(self.land_address_formats) return self.generator.parse(pattern)
:example 세종특별자치시 도움5로 19 (어진동)
def road_address(self): """ :example 세종특별자치시 도움5로 19 (어진동) """ pattern = self.random_element(self.road_address_formats) return self.generator.parse(pattern)
:example 가나아파트 가동 102호
def address_detail(self): """ :example 가나아파트 가동 102호 """ pattern = self.bothify(self.random_element( self.address_detail_formats)) return self.generator.parse(pattern)
:example 도움5로
def road(self): """ :example 도움5로 """ pattern = self.random_element(self.road_formats) return self.generator.parse(pattern)
:example 고양시
def city(self): """ :example 고양시 """ pattern = self.random_element(self.cities) return self.generator.parse(pattern)
:example 가나동
def town(self): """ :example 가나동 """ pattern = self.random_element(self.town_formats) return self.generator.parse(pattern)
:example 김구아파트
def building_name(self): """ :example 김구아파트 """ pattern = self.random_element(self.building_name_formats) return self.generator.parse(pattern)