update bots

This commit is contained in:
2026-05-18 14:15:59 +07:00
parent b0ce866a2f
commit b9054d178e
5775 changed files with 832577 additions and 38 deletions

View File

@@ -0,0 +1,195 @@
from collections import OrderedDict
from typing import Dict, List, Optional
from ...typing import CardType, CreditCard, DateParseType
from .. import BaseProvider
localized = True
class Provider(BaseProvider):
"""Implement default credit card provider for Faker.
For all methods that take ``card_type`` as an argument, a random card type
will be used if the supplied value is ``None``. The list of valid card types
includes ``'amex'``, ``'diners'``, ``'discover'``, ``'jcb'``, ``'jcb15'``,
``'jcb16'``, ``'maestro'``, ``'mastercard'``, ``'visa'``, ``'visa13'``,
``'visa16'``, and ``'visa19'``.
Sources:
- https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_.28IIN.29
- https://www.regular-expressions.info/creditcard.html
- https://creditcardjs.com/credit-card-type-detection
"""
prefix_maestro: List[str] = [
"5018",
"5020",
"5038",
"56##",
"57##",
"58##",
"6304",
"6759",
"6761",
"6762",
"6763",
"0604",
"6390",
]
prefix_mastercard: List[str] = [
"51",
"52",
"53",
"54",
"55",
"222%",
"223",
"224",
"225",
"226",
"227",
"228",
"229",
"23",
"24",
"25",
"26",
"270",
"271",
"2720",
]
prefix_visa: List[str] = ["4"]
prefix_amex: List[str] = ["34", "37"]
prefix_discover: List[str] = ["6011", "65"]
prefix_diners: List[str] = ["300", "301", "302", "303", "304", "305", "36", "38"]
prefix_jcb16: List[str] = ["35"]
prefix_jcb15: List[str] = ["2131", "1800"]
credit_card_types: Dict[str, CreditCard] = OrderedDict(
(
("maestro", CreditCard("Maestro", prefix_maestro, 12, security_code="CVV")),
(
"mastercard",
CreditCard("Mastercard", prefix_mastercard, 16, security_code="CVV"),
),
("visa16", CreditCard("VISA 16 digit", prefix_visa)),
("visa13", CreditCard("VISA 13 digit", prefix_visa, 13)),
("visa19", CreditCard("VISA 19 digit", prefix_visa, 19)),
(
"amex",
CreditCard(
"American Express",
prefix_amex,
15,
security_code="CID",
security_code_length=4,
),
),
("discover", CreditCard("Discover", prefix_discover)),
("diners", CreditCard("Diners Club / Carte Blanche", prefix_diners, 14)),
("jcb15", CreditCard("JCB 15 digit", prefix_jcb15, 15)),
("jcb16", CreditCard("JCB 16 digit", prefix_jcb16)),
)
)
credit_card_types["visa"] = credit_card_types["visa16"]
credit_card_types["jcb"] = credit_card_types["jcb16"]
luhn_lookup = {
"0": 0,
"1": 2,
"2": 4,
"3": 6,
"4": 8,
"5": 1,
"6": 3,
"7": 5,
"8": 7,
"9": 9,
}
def credit_card_provider(self, card_type: Optional[CardType] = None) -> str:
"""Generate a credit card provider name."""
if card_type is None:
card_type = self.random_element(self.credit_card_types.keys()) # type: ignore[assignment]
return self._credit_card_type(card_type).name
def credit_card_number(self, card_type: Optional[CardType] = None) -> str:
"""Generate a valid credit card number."""
card = self._credit_card_type(card_type)
prefix: str = self.random_element(card.prefixes)
number = self._generate_number(self.numerify(prefix), card.length)
return number
def credit_card_expire(
self,
start: DateParseType = "now",
end: DateParseType = "+10y",
date_format: str = "%m/%y",
) -> str:
"""Generate a credit card expiry date.
This method uses |date_time_between| under the hood to generate the
expiry date, so the ``start`` and ``end`` arguments work in the same way
here as it would in that method. For the actual formatting of the expiry
date, |strftime| is used and ``date_format`` is simply passed
to that method.
"""
expire_date = self.generator.date_time_between(start, end)
return expire_date.strftime(date_format)
def credit_card_full(self, card_type: Optional[CardType] = None) -> str:
"""Generate a set of credit card details."""
card = self._credit_card_type(card_type)
tpl = "{provider}\n{owner}\n{number} {expire_date}\n{security}: {security_nb}\n"
tpl = tpl.format(
provider=card.name,
owner=self.generator.parse("{{first_name}} {{last_name}}"),
number=self.credit_card_number(card),
expire_date=self.credit_card_expire(),
security=card.security_code,
security_nb=self.credit_card_security_code(card),
)
return self.generator.parse(tpl)
def credit_card_security_code(self, card_type: Optional[CardType] = None) -> str:
"""Generate a credit card security code."""
sec_len = self._credit_card_type(card_type).security_code_length
return self.numerify("#" * sec_len)
def _credit_card_type(self, card_type: Optional[CardType] = None) -> CreditCard:
"""Generate a random CreditCard instance of the specified card type."""
if card_type is None:
card_type = self.random_element(self.credit_card_types.keys()) # type: ignore[assignment]
elif isinstance(card_type, CreditCard):
return card_type
return self.credit_card_types[card_type] # type: ignore[index]
def _generate_number(self, prefix: str, length: int) -> str:
"""Generate a credit card number.
The ``prefix`` argument is the start of the CC number as a string which
may contain any number of digits. The ``length`` argument is the length
of the CC number to generate which is typically 13 or 16.
"""
number = prefix
# Generate random char digits
number += "#" * (length - len(prefix) - 1)
number = self.numerify(number)
reverse = number[::-1]
# Calculate sum
tot = 0
pos = 0
while pos < length - 1:
tot += Provider.luhn_lookup[reverse[pos]]
if pos != (length - 2):
tot += int(reverse[pos + 1])
pos += 2
# Calculate check digit
check_digit = (10 - (tot % 10)) % 10
number += str(check_digit)
return number

View File

@@ -0,0 +1,7 @@
from .. import Provider as CreditCardProvider
class Provider(CreditCardProvider):
"""Implement credit card provider for ``en_US`` locale."""
pass

View File

@@ -0,0 +1,124 @@
from collections import OrderedDict
from faker.typing import CreditCard
from .. import Provider as CreditCardProvider
class Provider(CreditCardProvider):
"""Implement credit card provider for ``fa_IR`` locale.
For all methods that take ``card_type`` as an argument, a random card type
will be used if the supplied value is ``None``. The list of valid card types
includes ``'ansar'``, ``'bim'``, ``'day'``, ``'eghtesad_novin'``,
``'ghavamin'``, ``'hekmat'``, ``'iran_zamin'``, ``'kar_afarin'``,
``'keshavarzi'``, ``'kosar'``, ``'maskan'``, ``'mehre_ghtesad'``,
``'meli'``, ``'mellal'``, ``'mellat'``, ``'parsian'``, ``'pasargad'``,
``'post_bank'``, ``'refah'``, ``'saderat'``, ``'saman'``, ``'sarmayeh'``,
``'sepah'``, ``'shahr'``, ``'sina'``, ``'tat'``, ``'tejarat'``, ``'tose'``,
and ``'tourism_bank'``.
Sources:
- https://way2pay.ir/21653
"""
prefix_ansar = ["627381"]
prefix_iran_zamin = ["505785"]
prefix_hekmat = ["636949"]
prefix_keshavarzi = ["603770"]
prefix_shahr = ["502806"]
prefix_mehr_eghtesad = ["606373"]
prefix_sarmayeh = ["639607"]
prefix_post_bank = ["627760"]
prefix_tose = ["628157"]
prefix_eghtesad_novin = ["627412"]
prefix_meli = ["603799"]
prefix_pasargad = ["502229"]
prefix_tourism_bank = ["505416"]
prefix_ghavamin = ["639599"]
prefix_day = ["502938"]
prefix_mellat = ["610433"]
prefix_tejarat = ["585983"]
prefix_moasse_mellal = ["606256"]
prefix_saman_bank = ["621986"]
prefix_kosar = ["505801"]
prefix_refah = ["589463"]
prefix_saderat = ["603761"]
prefix_tat = ["621986"]
prefix_sina = ["639346"]
prefix_kar_afarin = ["627488"]
prefix_sepah = ["589210"]
prefix_maskan = ["628023"]
prefix_parsian = ["622106"]
prefix_bim = ["627961"]
credit_card_types = OrderedDict(
(
("ansar", CreditCard("انصار", prefix_ansar, 16, security_code="CVV2")),
(
"iran_zamin",
CreditCard("ایران زمین", prefix_iran_zamin, 16, security_code="CVV2"),
),
("hekmat", CreditCard("حکمت", prefix_hekmat, 16, security_code="CVV2")),
(
"keshavarzi",
CreditCard("کشاورزی", prefix_keshavarzi, 16, security_code="CVV2"),
),
("shahr", CreditCard("شهر", prefix_shahr, 16, security_code="CVV2")),
(
"mehre_ghtesad",
CreditCard("مهراقتصاد", prefix_mehr_eghtesad, 16, security_code="CVV2"),
),
(
"sarmayeh",
CreditCard("سرمایه", prefix_sarmayeh, 16, security_code="CVV2"),
),
(
"post_bank",
CreditCard("پست بانک", prefix_post_bank, 16, security_code="CVV2"),
),
("tose", CreditCard("توسعه", prefix_tose, 16, security_code="CVV2")),
(
"eghtesad_novin",
CreditCard("اقتصاد نوین", prefix_eghtesad_novin, 16, security_code="CVV2"),
),
("meli", CreditCard("ملی", prefix_meli, 16, security_code="CVV2")),
(
"pasargad",
CreditCard("پاسارگاد", prefix_pasargad, 16, security_code="CVV2"),
),
(
"tourism_bank",
CreditCard("گردشگری", prefix_tourism_bank, 16, security_code="CVV2"),
),
(
"ghavamin",
CreditCard("قوامین", prefix_ghavamin, 16, security_code="CVV2"),
),
("day", CreditCard("دی", prefix_day, 16, security_code="CVV2")),
("mellat", CreditCard("ملت", prefix_mellat, 16, security_code="CVV2")),
("tejarat", CreditCard("تجارت", prefix_tejarat, 16, security_code="CVV2")),
(
"mellal",
CreditCard("ملل", prefix_moasse_mellal, 16, security_code="CVV2"),
),
("saman", CreditCard("سامان", prefix_saman_bank, 16, security_code="CVV2")),
("kosar", CreditCard("کوثر", prefix_kosar, 16, security_code="CVV2")),
("refah", CreditCard("رفاه", prefix_refah, 16, security_code="CVV2")),
("saderat", CreditCard("صادرات", prefix_saderat, 16, security_code="CVV2")),
("tat", CreditCard("تات", prefix_tat, 16, security_code="CVV2")),
("sina", CreditCard("سینا", prefix_sina, 16, security_code="CVV2")),
(
"kar_afarin",
CreditCard("کار آفرین", prefix_kar_afarin, 16, security_code="CVV2"),
),
("sepah", CreditCard("سپه", prefix_sepah, 16, security_code="CVV2")),
("maskan", CreditCard("مسکن", prefix_maskan, 16, security_code="CVV2")),
(
"parsian",
CreditCard("پارسیان", prefix_parsian, 16, security_code="CVV2"),
),
("bim", CreditCard("صنعت و معدن", prefix_bim, 16, security_code="CVV2")),
)
)

View File

@@ -0,0 +1,299 @@
from collections import OrderedDict
from faker.typing import CreditCard
from .. import Provider as CreditCardProvider
class Provider(CreditCardProvider):
"""Implementation of ``pt_PT`` locale credit card
For all methods that take ``card_type`` as an argument a random card type
will be used if the supplied value is ``None``. The list of valid card types
includes ``'visa'``, ``'mastercard'`` and ``'maestro'``.
Source: https://bincheck.org/portugal
"""
prefix_visa = [
"400131",
"400190",
"400817",
"402192",
"402947",
"402956",
"403005",
"403006",
"403007",
"403008",
"403271",
"404520",
"404530",
"405758",
"406170",
"406475",
"407548",
"407549",
"407575",
"408237",
"408239",
"409842",
"409843",
"410000",
"410344",
"410345",
"410553",
"410557",
"411635",
"411700",
"411701",
"411869",
"412487",
"412488",
"412489",
"412657",
"412782",
"412990",
"413014",
"413793",
"413871",
"415158",
"415159",
"415170",
"415171",
"415174",
"415175",
"415194",
"415195",
"415238",
"415272",
"415273",
"415403",
"415404",
"415405",
"415440",
"415441",
"415569",
"415920",
"415961",
"416952",
"416963",
"416970",
"417005",
"417091",
"417092",
"417337",
"418847",
"419022",
"419682",
"419683",
"419684",
"421149",
"421510",
"422080",
"422240",
"422241",
"422414",
"422417",
"422597",
"422869",
"423392",
"423393",
"424118",
"424184",
"424208",
"424661",
"425509",
"425510",
"425906",
"426150",
"426360",
"426370",
"427256",
"427304",
"427729",
"427770",
"427867",
"428139",
"428184",
"428185",
"428186",
"428187",
"429711",
"430240",
"430241",
"431926",
"433390",
"433391",
"433511",
"433512",
"433513",
"433599",
"433618",
"433622",
"433966",
"437886",
"438257",
"439070",
"440637",
"440644",
"440645",
"442664",
"443977",
"443978",
"444224",
"444227",
"445961",
"445962",
"446140",
"446144",
"449389",
"450915",
"451156",
"451166",
"454755",
"455250",
"455290",
"455292",
"455658",
"456811",
"456812",
"457031",
"458058",
"458059",
"459432",
"459433",
"459449",
"460340",
"460341",
"460342",
"461247",
"461248",
"461249",
"462731",
"462732",
"464406",
"465964",
"476066",
"476067",
"476068",
"476069",
"476070",
"476071",
"476329",
"477920",
"477921",
"477922",
"477947",
"477989",
"478062",
"478063",
"479702",
"479736",
"483088",
"485672",
"486449",
"486457",
"489434",
"489485",
"490772",
"490830",
"490831",
"490832",
"490841",
"490863",
"491213",
"491546",
"491547",
"491613",
"492194",
"493402",
"493480",
"493800",
"493801",
"493830",
"498800",
"499968",
"499969",
"499986",
"422239",
"422041",
"464409",
"464408",
]
prefix_mastercard = [
"510122",
"510123",
"512556",
"518772",
"519744",
"519774",
"520342",
"524552",
"524878",
"525625",
"525808",
"526819",
"527014",
"528024",
"529119",
"530267",
"530770",
"532355",
"536468",
"541171",
"541557",
"542081",
"542098",
"542858",
"543099",
"543116",
"543123",
"544051",
"544052",
"544233",
"547260",
"547459",
"548168",
"548169",
"552727",
"552755",
"553057",
"554506",
"554517",
"554518",
"556660",
"557836",
"557882",
"557883",
"557888",
]
prefix_maestro = [
"501654",
"501659",
"670530",
"670811",
"670812",
"676938",
"676938",
"677393",
"677707",
"670835",
"670817",
]
credit_card_types = OrderedDict(
(
(
"maestro",
CreditCard("Maestro", prefix_maestro, 16, security_code="CVV2"),
),
(
"mastercard",
CreditCard("Mastercard", prefix_mastercard, 16, security_code="CVV2"),
),
("visa", CreditCard("Visa", prefix_visa, 16, security_code="CVV2")),
)
)

View File

@@ -0,0 +1,115 @@
from collections import OrderedDict
from typing import Optional
from faker.providers.person.ru_RU import translit
from faker.typing import CardType, CreditCard
from .. import Provider as CreditCardProvider
class Provider(CreditCardProvider):
"""Implement credit card provider for ``ru_RU`` locale.
For all methods that take ``card_type`` as an argument, a random card type
will be used if the supplied value is ``None``. The list of valid card types
includes ``'amex'``, ``'maestro'``, ``'mastercard'``, ``'mir'``,
``'unionpay'``, and ``'visa'``.
Sources:
- https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_(IIN)
"""
prefix_visa = ["4"]
prefix_mastercard = [
"51",
"52",
"53",
"54",
"55",
"222%",
"223",
"224",
"225",
"226",
"227",
"228",
"229",
"23",
"24",
"25",
"26",
"270",
"271",
"2720",
]
prefix_mir = ["2200", "2201", "2202", "2203", "2204"]
prefix_maestro = [
"50",
"56",
"57",
"58",
"59",
"60",
"61",
"62",
"63",
"64",
"65",
"66",
"67",
"68",
"69",
]
prefix_amex = ["34", "37"]
prefix_unionpay = ["62", "81"]
credit_card_types = OrderedDict(
(
("visa", CreditCard("Visa", prefix_visa, security_code="CVV2")),
(
"mastercard",
CreditCard("Mastercard", prefix_mastercard, security_code="CVC2"),
),
("mir", CreditCard("МИР", prefix_mir)),
("maestro", CreditCard("Maestro", prefix_maestro, security_code="CVV2")),
(
"amex",
CreditCard(
"American Express",
prefix_amex,
15,
security_code="CID",
security_code_length=4,
),
),
("unionpay", CreditCard("Union Pay", prefix_unionpay)),
)
)
def credit_card_full(self, card_type: Optional[CardType] = None) -> str:
"""Generate a set of credit card details."""
card = self._credit_card_type(card_type)
tpl = "{provider}\n{owner}\n{number} {expire_date}\n{security}: {security_nb}\n{issuer}"
tpl = tpl.format(
provider=card.name,
owner=translit(
self.generator.parse(
self.random_element(
[
"{{first_name_male}} {{last_name_male}}",
"{{first_name_female}} {{last_name_female}}",
]
)
)
),
number=self.credit_card_number(card),
expire_date=self.credit_card_expire(),
security=card.security_code,
security_nb=self.credit_card_security_code(card),
issuer=self.generator.parse("{{bank}}"),
)
return self.generator.parse(tpl)

View File

@@ -0,0 +1,58 @@
from collections import OrderedDict
from typing import Optional
from faker.providers.person.uk_UA import translit
from faker.typing import CardType, CreditCard
from .. import Provider as CreditCardProvider
class Provider(CreditCardProvider):
"""Implement credit card provider for ``uk_UA`` locale.
https://blog.ipay.ua/uk/sekrety-bankovskix-kart-kak-identificirovat-bank-po-nomeru-karty/
"""
prefix_visa = ["4"]
prefix_mastercard = ["51", "52", "53", "54"]
prefix_prostir = ["9"]
prefix_maestro = ["6762"]
credit_card_types = OrderedDict(
(
("visa", CreditCard("Visa", prefix_visa, security_code="CVV2")),
("mastercard", CreditCard("Mastercard", prefix_mastercard, security_code="CVC2")),
("prostir", CreditCard("ПРОСТІР", prefix_prostir, security_code="CVC2")),
("maestro", CreditCard("Maestro", prefix_maestro, security_code="CVV")),
)
)
def credit_card_full(self, card_type: Optional[CardType] = None) -> str:
"""Generate UA Credit Card:
Supported card types 'visa', 'mastercard', 'prostir', 'maestro'
:sample:
:sample: card_type="prostir"
:sample: card_type="mastercard"
"""
card = self._credit_card_type(card_type)
tpl = "{provider}\n{owner}\n{number} {expire_date}\n{security}: {security_nb}\n{issuer}"
tpl = tpl.format(
provider=card.name,
owner=translit(
self.generator.parse(
self.random_element(
[
"{{first_name_male}} {{last_name_male}}",
"{{first_name_female}} {{last_name_female}}",
]
)
)
),
number=self.credit_card_number(card),
expire_date=self.credit_card_expire(),
security=card.security_code,
security_nb=self.credit_card_security_code(card),
issuer=self.generator.parse("{{bank}}"),
)
return self.generator.parse(tpl)

View File

@@ -0,0 +1,36 @@
from collections import OrderedDict
from typing import Optional
from faker.providers.credit_card import Provider as CreditCardProvider
from faker.typing import CardType, CreditCard
class Provider(CreditCardProvider):
"""Custom credit card provider for the zh_CN locale."""
prefix_unionpay = ["62"] # UnionPay cards typically start with 62
prefix_visa = ["4"]
prefix_mastercard = ["51", "52", "53", "54", "55"]
credit_card_types = OrderedDict(
(
("unionpay", CreditCard("UnionPay", prefix_unionpay, security_code="CVN2")),
("visa", CreditCard("Visa", prefix_visa, security_code="CVV2")),
("mastercard", CreditCard("Mastercard", prefix_mastercard, security_code="CVC2")),
)
)
def credit_card_full(self, card_type: Optional[CardType] = None) -> str:
"""Generate a full Chinese credit card with details."""
card = self._credit_card_type(card_type)
tpl = "{provider}\n{owner}\n{number} {expire_date}\n{security}: {security_nb}\n{issuer}"
tpl = tpl.format(
provider=card.name,
owner=self.generator.parse("{{first_name}}{{last_name}}"),
number=self.credit_card_number(card),
expire_date=self.credit_card_expire(),
security=card.security_code,
security_nb=self.credit_card_security_code(card),
issuer=self.generator.parse("{{bank}}"),
)
return self.generator.parse(tpl)