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,63 @@
import re
from string import ascii_uppercase
from .. import BaseProvider, ElementsType
localized = True
def calculate_vin_str_weight(s: str, weight_factor: list) -> int:
"""
multiply s(str) by weight_factor char by char
e.g.
input: s="ABCDE", weight_factor=[1, 2, 3, 4, 5]
return: A*1 + B*2 + C*3 + D*4 + E*5
will multiply 0 when len(weight_factor) less than len(s)
"""
def _get_char_weight(c: str) -> int:
"""A=1, B=2, ...., I=9,
J=1, K=2, ..., R=9,
S=2, T=3, ..., Z=9
"""
if ord(c) <= 64: # 0-9
return int(c)
if ord(c) <= 73: # A-I
return ord(c) - 64
if ord(c) <= 82: # J-R
return ord(c) - 73
# S-Z
return ord(c) - 81
res = 0
for i, c in enumerate(s):
res += _get_char_weight(c) * weight_factor[i] if i < len(weight_factor) else 0
return res
class Provider(BaseProvider):
"""Implement default automotive provider for Faker."""
license_formats: ElementsType = ()
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(ascii_uppercase),
self.random_element(self.license_formats),
)
return self.numerify(temp)
def vin(self) -> str:
"""Generate vin number."""
vin_chars = "1234567890ABCDEFGHJKLMNPRSTUVWXYZ" # I, O, Q are restricted
front_part = self.bothify("????????", letters=vin_chars)
rear_part = self.bothify("????####", letters=vin_chars)
front_part_weight = calculate_vin_str_weight(front_part, [8, 7, 6, 5, 4, 3, 2, 10])
rear_part_weight = calculate_vin_str_weight(rear_part, [9, 8, 7, 6, 5, 4, 3, 2])
checksum = (front_part_weight + rear_part_weight) % 11
checksum_char = "X" if checksum == 10 else str(checksum)
return front_part + checksum_char + rear_part

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ar_BH`` locale.
Source:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Bahrain
"""
license_formats = ("######",)

View File

@@ -0,0 +1,20 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ar_DZ`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Algeria
"""
WILAYA_CODES = tuple(f"{i:02d}" for i in range(1, 59))
VEHICLE_CLASSES = tuple("123456789")
def license_plate(self) -> str:
serial = self.numerify("#####")
vehicle_class = self.random_element(self.VEHICLE_CLASSES)
year = self.numerify("##")
wilaya = self.random_element(self.WILAYA_CODES)
return f"{serial} {vehicle_class}{year} {wilaya}"

View File

@@ -0,0 +1,53 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ar_JO`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Jordan
"""
license_formats = (
"{{initials}}-####",
"{{initials}}-#####",
)
def initials(self) -> str:
"""Generate an initial number for license plates."""
return self.random_element(
[
"1", # Ministers
"2",
"3", # Parliament
"5", # General Government
"6", # Aqaba free zone
"7",
"8", # Diplomatic
"9", # Temporary
"10",
"23", # Passenger cars
"38",
"39", # Crew cabs
"41",
"42", # Light goods vehicles
"44", # Tractors
"46", # Motorcycles and scooters
"50", # Taxi
"56", # Small buses
"58", # Coaches
"60", # HGVs
"70", # Rental Cars
"71", # Trailer
"90", # Army
"95", # Ambulance
"96", # Gendarmerie
"99", # Police
]
)
def license_plate(self) -> str:
"""Generate a license plate."""
pattern: str = self.random_element(self.license_formats)
return self.numerify(self.generator.parse(pattern))

View File

@@ -0,0 +1,64 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ar_PS`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_Palestinian_National_Authority
"""
license_formats = (
# Private vehicles
"{{district}}-####-3#",
"{{district}}-####-4#",
"{{district}}-####-7#",
"{{district}}-####-9#",
# Public transport
"{{district}}-####-30",
# Authority vehicles
"####",
# New police vehicles
"####-99",
# Gaza strip after 2012
# Private
"1-####-0#",
"3-####-0#",
# Commercial
"1-####-1#",
"3-####-1#",
# Public
"1-####-2#",
"3-####-2#",
# Municipal
"1-####-4#",
"3-####-4#",
# Governmental, and Governmental personal vehicles
"1-####-5#",
"3-####-5#",
)
def district(self) -> str:
"""Generate a district code for license plates."""
return self.random_element(
[
# Gaza Strip
"1",
"3",
# Northern West Bank (Nablus, Tulkarm, Qalqilya, Jenin)
"4",
"7",
# Central West Bank (Ramallah, Jerusalem, Jericho)
"5",
"6",
# Southern West Bank (Bethlehem, Hebron)
"8",
"9",
]
)
def license_plate(self) -> str:
"""Generate a license plate."""
pattern: str = self.random_element(self.license_formats)
return self.numerify(self.generator.parse(pattern))

View File

@@ -0,0 +1,89 @@
import re
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ar_SA`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Saudi_Arabia
.. |license_plate_en| replace::
:meth:`license_plate_en()`
"""
LICENSE_FORMAT_EN = "#### ???"
LICENSE_FORMAT_AR = "? ? ? ####"
PLATE_CHARS_EN = "ABDEGHJKLNRSTUVXZ"
PLATE_CHARS_AR = "أبدعقهحكلنرسطوىصم"
PLATE_MAP = {
"A": "ا",
"B": "ب",
"D": "د",
"E": "ع",
"G": "ق",
"H": "ه",
"J": "ح",
"K": "ك",
"L": "ل",
"N": "ن",
"R": "ر",
"S": "س",
"T": "ط",
"U": "و",
"V": "ى",
"X": "ص",
"Z": "م",
"0": "٠",
"1": "١",
"2": "٢",
"3": "٣",
"4": "٤",
"5": "٥",
"6": "٦",
"7": "٧",
"8": "٨",
"9": "٩",
}
def license_plate_en(self) -> str:
"""Generate a license plate in Latin/Western characters."""
return self.bothify(
self.LICENSE_FORMAT_EN,
letters=self.PLATE_CHARS_EN,
)
def license_plate_ar(self) -> str:
"""Generate a license plate in Arabic characters.
This method first generates a license plate in Latin/Western characters
using |license_plate_en|, and the result is translated internally to
generate the Arabic counterpart which serves as this method's return
value.
"""
english_plate = self.license_plate_en()
return self._translate_license_plate(english_plate)
def _translate_license_plate(self, license_plate: str) -> str:
nums = list(reversed(license_plate[0:4]))
chars = list(license_plate[5:8])
numerated = re.sub(
r"\#",
lambda x: self.PLATE_MAP[nums.pop()],
self.LICENSE_FORMAT_AR,
)
ar_plate = re.sub(
r"\?",
lambda x: self.PLATE_MAP[chars.pop()],
numerated,
)
return ar_plate
def license_plate(self, ar: bool = True) -> str:
return self.license_plate_ar() if ar else self.license_plate_en()

View File

@@ -0,0 +1,97 @@
import re
from .. import Provider as AutoProvider
class Provider(AutoProvider):
"""Implement license formats for ``az_AZ`` locale."""
license_formats = ("##-??-###",)
ascii_uppercase_azerbaijan = "ABCDEFGHXIJKQLMNOPRSTUVYZ"
license_plate_initial_numbers = (
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"90",
"11",
"12",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
"32",
"33",
"34",
"35",
"36",
"37",
"38",
"39",
"40",
"41",
"42",
"43",
"44",
"45",
"46",
"47",
"48",
"49",
"50",
"51",
"52",
"53",
"54",
"55",
"56",
"57",
"58",
"59",
"60",
"61",
"62",
"63",
"64",
"65",
"66",
"67",
"68",
"69",
"70",
"71",
"72",
"77",
"85",
)
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.ascii_uppercase_azerbaijan),
self.random_element(self.license_formats),
)
temp = temp.replace("##", self.random_element(self.license_plate_initial_numbers), 1)
# temp = temp.format(self.random_element(range(1, 999)))
return self.numerify(temp)

View File

@@ -0,0 +1,253 @@
from faker.providers.person.bn_BD import translate_to_bengali_digits
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``bn_BD`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Bangladesh
"""
# noinspection DuplicatedCode
cities = (
"বরগুনা",
"বরিশাল",
"বরিশাল মেট্রো",
"ভোলা",
"বান্দরবান",
"ব্রাহ্মণবাড়িয়া",
"বাগেরহাট",
"বগুড়া",
"চাঁদপুর",
"চট্টগ্রাম",
"চট্ট মেট্রো",
"কুমিল্লা",
"কক্সবাজার",
"চুয়াডাঙ্গা",
"ঢাকা",
"ঢাকা মেট্রো",
"দিনাজপুর",
"ফরিদপুর",
"ফেনী",
"গাজীপুর",
"গোপালগঞ্জ",
"গাইবান্ধা",
"হবিগঞ্জ",
"ঝালকাঠি",
"যশোর",
"ঝিনাইদহ",
"জামালপুর",
"জয়পুরহাট",
"খাগড়াছড়ি",
"কিশোরগঞ্জ",
"খুলনা",
"খুলনা মেট্রো",
"কুষ্টিয়া",
"কুড়িগ্রাম",
"লক্ষ্মীপুর",
"লালমনিরহাট",
"মাদারীপুর",
"মানিকগঞ্জ",
"মুন্সীগঞ্জ",
"মাগুরা",
"মেহেরপুর",
"ময়মনসিংহ",
"মৌলভীবাজার",
"নোয়াখালী",
"নারায়ণগঞ্জ",
"নরসিংদী",
"নড়াইল",
"নেত্রকোণা",
"নওগাঁ",
"নাটোর",
"চাঁপাইনবাবগঞ্জ",
"নীলফামারী",
"পটুয়াখালী",
"পিরোজপুর",
"পাবনা",
"পঞ্চগড়",
"রাঙ্গামাটি",
"রাজবাড়ী",
"রাজশাহী",
"রাজ মেট্রো",
"রংপুর",
"শরীয়তপুর",
"সাতক্ষীরা",
"শেরপুর",
"সিরাজগঞ্জ",
"সুনামগঞ্জ",
"সিলেট",
"সিলেট মেট্রো",
"টাঙ্গাইল",
"ঠাকুরগাঁও",
)
vehicle_category_letters = (
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
)
vehicle_category_numbers = (
"১১",
"১২",
"১৩",
"১৪",
"১৫",
"১৬",
"১৭",
"১৮",
"১৯",
"২০",
"২১",
"২২",
"২৩",
"২৪",
"২৫",
"২৬",
"২৭",
"২৮",
"২৯",
"৩০",
"৩১",
"৩২",
"৩৩",
"৩৪",
"৩৫",
"৩৬",
"৩৭",
"৩৮",
"৩৯",
"",
"৪১",
"৪২",
"৪৩",
"",
"৪৫",
"৪৬",
"",
"৪৮",
"৪৯",
"৫০",
"৫১",
"৫২",
"৫৩",
"৫৪",
"৫৫",
"৫৬",
"৫৭",
"৫৮",
"৫৯",
"৬০",
"৬১",
"৬২",
"৬৩",
"৬৪",
"৬৫",
"৬৬",
"৬৭",
"৬৮",
"৬৯",
"",
"৭১",
"৭২",
"৭৩",
"",
"৭৫",
"৭৬",
"",
"৭৮",
"৭৯",
"৮০",
"৮১",
"৮২",
"৮৩",
"৮৪",
"৮৫",
"৮৬",
"৮৭",
"৮৮",
"৮৯",
"৯০",
"৯১",
"৯২",
"৯৩",
"৯৪",
"৯৫",
"৯৬",
"৯৭",
"৯৮",
"৯৯",
)
vehicle_serial_number_formats = ("%###",)
license_plate_formats = (
"{{city_name}}-{{vehicle_category_letter}} {{vehicle_category_number}}-{{vehicle_serial_number}}",
)
def city_name(self) -> str:
"""
:example: 'ঢাকা মেট্রো'
"""
return self.random_element(self.cities)
def vehicle_category_letter(self) -> str:
"""
:example: ''
"""
return self.random_element(self.vehicle_category_letters)
def vehicle_category_number(self) -> str:
"""
:example: '১১'
"""
return self.random_element(self.vehicle_category_numbers)
def vehicle_serial_number(self) -> str:
"""
Generate a 4 digits vehicle serial number.
:example: '৫৪৩২'
"""
return translate_to_bengali_digits(self.numerify(self.random_element(self.vehicle_serial_number_formats)))
def license_plate(self) -> str:
"""
Generate a license plate.
:example: 'বরিশাল-ভ ৬৭-৪৫৯৩'
"""
pattern: str = self.random_element(self.license_plate_formats)
return self.generator.parse(pattern)

View File

@@ -0,0 +1,9 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``da_DK`` locale.
Source: https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Denmark
"""
license_formats = ("?? ## ###",)

View File

@@ -0,0 +1,177 @@
import string
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``de_AT`` locale.
Sources:
- https://de.wikipedia.org/wiki/Kfz-Kennzeichen_(%C3%96sterreich)
"""
license_plate_prefix = (
"A",
"AM",
"B",
"BA",
"BB",
"BD",
"BG",
"BH",
"BK",
"BL",
"BM",
"BN",
"BP",
"BR",
"BZ",
"DL",
"DO",
"E",
"EF",
"EU",
"FB",
"FE",
"FF",
"FK",
"FR",
"FV",
"FW",
"G",
"GB",
"GD",
"GF",
"GK",
"GM",
"GR",
"GS",
"GU",
"HA",
"HB",
"HE",
"HF",
"HL",
"HO",
"I",
"IL",
"IM",
"JE",
"JO",
"JU",
"JW",
"K",
"KB",
"KD",
"KF",
"KG",
"KI",
"KK",
"KL",
"KO",
"KR",
"KS",
"KU",
"L",
"LA",
"LB",
"LD",
"LE",
"LF",
"LI",
"LK",
"LL",
"LN",
"LZ",
"MA",
"MD",
"ME",
"MI",
"MT",
"MU",
"MZ",
"N",
"ND",
"NK",
"O",
"OP",
"OW",
"P",
"PE",
"PL",
"PT",
"RA",
"RE",
"RI",
"RO",
"S",
"SB",
"SD",
"SE",
"SK",
"SL",
"SO",
"SP",
"SR",
"ST",
"SV",
"SW",
"SZ",
"T",
"TA",
"TD",
"TK",
"TU",
"UU",
"V",
"VB",
"VD",
"VI",
"VK",
"VL",
"VO",
"W",
"WB",
"WD",
"WE",
"WK",
"WL",
"WN",
"WO",
"WT",
"WU",
"WY",
"WZ",
"ZE",
"ZT",
"ZW",
)
license_plate_suffix_for_one_starting_letter = ("-%# ???", "-%## ???", "-%## ??", "-%### ??", "-%### ?", "-%#### ?")
license_plate_suffix_for_two_starting_letters = (
"-% ???",
"-%# ???",
"-%# ??",
"-%## ??",
"-%## ?",
"-%### ?",
)
def license_plate(self) -> str:
"""Generate a license plate."""
prefix: str = self.random_element(self.license_plate_prefix)
if len(prefix) == 1:
suffix = self.bothify(
self.random_element(self.license_plate_suffix_for_one_starting_letter),
letters=string.ascii_uppercase,
)
else:
suffix = self.bothify(
self.random_element(self.license_plate_suffix_for_two_starting_letters),
letters=string.ascii_uppercase,
)
return prefix + suffix

View File

@@ -0,0 +1,44 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``de_CH`` locale.
Sources:
- https://de.wikipedia.org/wiki/Kontrollschild_(Schweiz)#Kantone
"""
__canton = (
("AG", "%## ###"),
("AR", "%# ###"),
("AI", "%# ###"),
("BL", "%## ###"),
("BS", "%## ###"),
("BE", "%## ###"),
("FR", "%## ###"),
("GE", "%## ###"),
("GL", "%# ###"),
("GR", "%## ###"),
("JU", "%# ###"),
("LU", "%## ###"),
("NE", "%## ###"),
("NW", "%# ###"),
("OW", "%# ###"),
("SH", "%# ###"),
("SZ", "%## ###"),
("SO", "%## ###"),
("SG", "%## ###"),
("TI", "%## ###"),
("TG", "%## ###"),
("UR", "%# ###"),
("VD", "%## ###"),
("VS", "%## ###"),
("ZG", "%## ###"),
("ZH", "%## ###"),
)
def license_plate(self) -> str:
"""Generate a license plate."""
plate: tuple = self.random_element(self.__canton)
return f"{plate[0]}-{self.numerify(plate[1])}".strip()

View File

@@ -0,0 +1,430 @@
import string
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``de_DE`` locale.
Sources:
- http://berlin.de/daten/liste-der-kfz-kennzeichen/kfz-kennz-d.csv
"""
license_plate_prefix = (
"A",
"AA",
"AB",
"ABI",
"ABG",
"AC",
"AE",
"AIC",
"AK",
"AM",
"AN",
"",
"AP",
"AS",
"AUR",
"AW",
"AZ",
"B",
"BA",
"BAD",
"BAR",
"BB",
"BC",
"BD",
"BGL",
"BI",
"BIR",
"BIT",
"BK",
"BL",
"BLK",
"BM",
"BN",
"BO",
"BOR",
"BOT",
"BP",
"BRA",
"BRB",
"BS",
"BT",
"BTF",
"BÜS",
"BW",
"BWL",
"BYL",
"BZ",
"C",
"CB",
"CE",
"CHA",
"CO",
"COC",
"COE",
"CUX",
"CW",
"D",
"DA",
"DAH",
"DAN",
"DAU",
"DBR",
"DD",
"DE",
"DEG",
"DEL",
"DGF",
"DH",
"DL",
"DLG",
"DN",
"Do",
"DON",
"DU",
"DÜW",
"E",
"EA",
"EB",
"EBE",
"ED",
"EE",
"EF",
"EI",
"EIC",
"EL",
"EM",
"EMD",
"EMS",
"EN",
"ER",
"ERB",
"ERH",
"ERZ",
"ES",
"ESW",
"EU",
"F",
"FB",
"FD",
"FDS",
"FF",
"FFB",
"FG",
"FL",
"FN",
"FO",
"FR",
"FRG",
"FRI",
"FS",
"FT",
"",
"G",
"GAP",
"GE",
"GER",
"GF",
"GG",
"GI",
"GL",
"GM",
"",
"GP",
"GR",
"GRZ",
"GS",
"GT",
"GTH",
"",
"GZ",
"H",
"HA",
"HAL",
"HAM",
"HAS",
"HB",
"HBN",
"HD",
"HDH",
"HE",
"HEF",
"HEI",
"HEL",
"HER",
"HF",
"HG",
"HGW",
"HH",
"HI",
"HL",
"HM",
"HN",
"HO",
"HOL",
"HOM",
"HP",
"HR",
"HRO",
"HS",
"HSK",
"HST",
"HU",
"HVL",
"HWI",
"HX",
"HZ",
"IGB",
"IK",
"IN",
"IZ",
"J",
"JL",
"K",
"KA",
"KB",
"KC",
"KE",
"KEH",
"KF",
"KG",
"KH",
"KI",
"KIB",
"KL",
"KLE",
"KN",
"KO",
"KR",
"KS",
"KT",
"KU",
"KÜN",
"KUS",
"KYF",
"L",
"LA",
"LAU",
"LB",
"LD",
"LDK",
"LDS",
"LER",
"LEV",
"LG",
"LI",
"LIF",
"LIP",
"LL",
"LM",
"",
"LOS",
"LRO",
"LSA",
"LSN",
"LU",
"LWL",
"M",
"MA",
"MB",
"MD",
"ME",
"MEI",
"MG",
"MI",
"MIL",
"MK",
"MKK",
"MM",
"MN",
"MOL",
"MOS",
"MR",
"MS",
"MSH",
"MSP",
"MST",
"MTK",
"",
"MÜR",
"MVL",
"MYK",
"MZ",
"MZG",
"N",
"NB",
"ND",
"NDH",
"NE",
"NEA",
"NES",
"NEW",
"NF",
"NI",
"NK",
"NL",
"NM",
"NMS",
"NOH",
"NOM",
"NR",
"NU",
"NVP",
"NW",
"NWM",
"OA",
"OAL",
"OB",
"OD",
"OE",
"OF",
"OG",
"OH",
"OHA",
"OHV",
"OHZ",
"OL",
"OPR",
"OS",
"OSL",
"OVP",
"P",
"PA",
"PAF",
"PAN",
"PB",
"PCH",
"PE",
"PF",
"PI",
"PIR",
"PLÖ",
"PM",
"PR",
"PS",
"R",
"RA",
"RD",
"RE",
"REG",
"RO",
"ROS",
"ROW",
"RP",
"RPL",
"RS",
"RT",
"RÜD",
"RÜG",
"RV",
"RW",
"RZ",
"S",
"SAD",
"SAL",
"SAW",
"SB",
"SC",
"SDL",
"SE",
"SG",
"SH",
"SHA",
"SHG",
"SHK",
"SHL",
"SI",
"SIG",
"SIM",
"SK",
"SL",
"SLF",
"SLK",
"SLS",
"SM",
"SN",
"SO",
"SOK",
"SÖM",
"SON",
"SP",
"SPN",
"SR",
"ST",
"STA",
"STD",
"SU",
"SÜW",
"SW",
"SZ",
"TDO",
"TBB",
"TF",
"TG",
"THL",
"THW",
"TIR",
"TÖL",
"TR",
"TS",
"",
"TUT",
"UE",
"UL",
"UM",
"UN",
"V",
"VB",
"VEC",
"VER",
"VIE",
"VK",
"VR",
"VS",
"W",
"WAF",
"WAK",
"WB",
"WE",
"WEN",
"WES",
"WF",
"WHV",
"WI",
"WIL",
"WL",
"WM",
"WN",
"WND",
"WO",
"WOB",
"WST",
"WT",
"WTM",
"",
"WUG",
"WUN",
"WW",
"WZ",
"Y",
"Z",
"ZW",
)
license_plate_suffix = (
"-??-%@@@",
"-?-%@@@",
)
def license_plate(self) -> str:
"""Generate a license plate."""
prefix: str = self.random_element(self.license_plate_prefix)
suffix = self.bothify(
self.random_element(self.license_plate_suffix),
letters=string.ascii_uppercase,
)
return prefix + suffix

View File

@@ -0,0 +1,23 @@
import re
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``el_GR`` locale."""
uppercase_letters = "ABEZHIKMNOPTYX"
license_formats = (
"??? ####",
"?? ####",
)
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.uppercase_letters),
self.random_element(self.license_formats),
)
return self.numerify(temp)

View File

@@ -0,0 +1,45 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``en_CA`` locale.
Sources:
- https://www.revolvy.com/main/index.php?s=Canadian%20licence%20plate%20designs%20and%20serial%20formats
"""
license_formats = (
# Alberta
"???-####",
# BC
"??# ##?",
"?? ####",
# Manitoba
"??? ###",
# New Brunswick
"??? ###",
# Newfoundland and Labrador
"??? ###",
# NWT
"######",
# Nova Scotia
"??? ###",
# Nunavut
"### ###",
# Ontario
"### ???",
"???? ###",
"??# ###",
"### #??",
"?? ####",
"GV??-###",
# PEI
"## ##??",
# Quebec
"?## ???",
# Saskatchewan
"### ???",
# Yukon
"???##",
)

View File

@@ -0,0 +1,15 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``en_GB`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_United_Kingdom
"""
license_formats = (
"??## ???",
"??##???",
)

View File

@@ -0,0 +1,32 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``en_NZ`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_New_Zealand
"""
license_formats = (
# Old plates
"??%##",
"??%###",
"??%###",
# Three letters since 2002
"A??%##",
"B??%##",
"C??%##",
"D??%##",
"E??%##",
"F??%##",
"G??%##",
"H??%##",
"J??%##",
"K??%##",
"L??%##",
"M??%##",
# After 2018
"N??%##",
)

View File

@@ -0,0 +1,70 @@
from string import ascii_uppercase
from typing import List
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``en_PH`` locale.
Vehicle registration in the Philippines has many controversies and is full
of quirks. On top of that, some terms are highly subject to interpretation
or to varying definitions when applied colloquially, e.g. "motor" usually
refers to either a machine's motor or a motorcycle, "vehicles" usually means
cars, SUVs, vans, and trucks but not motorcycles. Please read any additional
notes of individual methods for more details.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_Philippines
"""
protocol_licenses = [str(x) for x in range(1, 18) if x != 15]
motorcycle_license_formats = [
"??####", # 1981 series
"??#####", # 2014 series
]
automobile_license_formats = [
"???###", # 1981 series
"???####", # 2014 series
]
license_formats = motorcycle_license_formats + automobile_license_formats
def _license_plate(self, license_format: List[str]) -> str:
return self.bothify(self.random_element(license_format), ascii_uppercase)
def protocol_license_plate(self) -> str:
"""Generate a protocol license plate.
.. note::
High ranking government officials are entitled to use low numbered
protocol license plates.
"""
return self.random_element(self.protocol_licenses)
def motorcycle_license_plate(self) -> str:
"""Generate a motorcycle license plate.
.. note::
Motorcycles and any improvised vehicle with a motorcycle as its base
are issued motorcycle license plates.
"""
return self._license_plate(self.motorcycle_license_formats)
def automobile_license_plate(self) -> str:
"""Generate an automobile license plate.
.. note::
Cars, SUVs, vans, trucks, and other 4-wheeled civilian vehicles are
considered automobiles for this purpose.
"""
return self._license_plate(self.automobile_license_formats)
def license_plate(self) -> str:
"""Generate a license plate.
.. note::
This method will never generate protocol plates, because such plates
are only for specific use cases.
"""
return self._license_plate(self.license_formats)

View File

@@ -0,0 +1,170 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``en_US`` locale.
Sources:
- https://en.wikipedia.org/wiki/United_States_license_plate_designs_and_serial_formats
"""
license_formats = (
# Alabama
"#??####",
"##??###",
# Alaska
"### ???",
# American Samoa
"####",
# Arizona
"???####",
# Arkansas
"### ???",
"###???",
# California
"#???###",
# Colarado
"###-???",
"???-###",
# Conneticut
"###-???",
# Delaware
"######",
# DC
"??-####",
# Florda
"??? ?##",
"### ???",
"?## #??",
"### #??",
# Georgia
"???####",
# Guam
"?? ####",
# Hawaii
"??? ###",
"H?? ###",
"Z?? ###",
"K?? ###",
"L?? ###",
"M?? ###",
# Idaho
"? ######",
"#? #####",
"#? ?####",
"#? ??###",
"#? #?#???",
"#? ####?",
"##? ####",
# Illinois
"?? #####",
"??# ####",
# Indiana
"###?",
"###??",
"###???",
# Iowa
"??? ###",
# Kansas
"### ???",
# Kentucky
"### ???",
# Louisiana
"### ???",
# Maine
"#### ??",
# Maryland
"#??####",
# Massachusetts
"#??? ##",
"#?? ###",
"### ??#",
"##? ?##",
# Michigan
"### ???",
"#?? ?##",
# Minnesota
"###-???",
# Mississippi
"??? ###",
# Missouri
"??# ?#?",
# Montana
"#-#####?",
"##-####?",
# Nebraska
"??? ###",
"#-?####",
"##-?###",
"##-??##",
# Nevada
"##?•###",
# New Hampshire
"### ####",
# New Jersey
"?##-???",
# New Mexico
"###-???",
"???-###",
# New York
"???-####",
# North Carolina
"###-????",
# North Dakota
"### ???",
# Nothern Mariana Islands
"??? ###",
# Ohio
"??? ####",
# Oklahoma
"???-###",
# Oregon
"### ???",
# Pennsylvania
"???-####",
# Peurto Rico
"???-###",
# Rhode Island
"###-###",
# South Carolina
"### #??",
# South Dakota
"#?? ###",
"#?? ?##",
"##? ###",
"##? ?##",
"##? ??#",
# Tennessee
"?##-##?",
# Texas
"???-####",
# Utah
"?## #??",
"?## #??",
# Vermont
"??? ###",
"##??#",
"#??##",
"###?#",
"#?###",
# US Virgin Islands
"??? ###",
# Virginia
"???-####",
# Washington
"???####",
"###-???",
# West Virginia
"#?? ###",
"??? ###",
# Wisconsin
"???-####",
"###-???",
# Wyoming
"#-#####",
"#-####?",
"##-#####",
"#?-????",
"##?-????",
)

View File

@@ -0,0 +1,87 @@
from collections import OrderedDict
from string import ascii_uppercase
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``es_AR`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Argentina
"""
license_plate_old_format_first_letter = ascii_uppercase.replace("YZ", "")
license_plate_new_first_letter = OrderedDict(
[
("A", 0.99),
("B", 0.001),
("C", 0.0001),
("D", 0.00001),
("E", 0.0000000001),
]
)
license_plate_new_second_letter = OrderedDict(
[
("A", 0.1),
("B", 0.1),
("C", 0.1),
("D", 0.1),
("E", 0.1),
("F", 0.1),
("G", 0.09),
("H", 0.08),
("I", 0.07),
("J", 0.06),
("K", 0.04),
("L", 0.03),
("M", 0.009),
("N", 0.007),
("O", 0.005),
("P", 0.004),
("Q", 0.001),
("R", 0.0009),
("S", 0.0008),
("T", 0.0007),
("U", 0.0006),
("V", 0.0005),
("W", 0.0003),
("X", 0.0002),
("Y", 0.0001),
("Z", 0.00005),
]
)
license_formats = OrderedDict(
[
("{{license_plate_old}}", 0.6),
("{{license_plate_mercosur}}", 0.4),
]
)
def license_plate_old(self) -> str:
"""Generate an old format license plate. Since 1995 to 2016"""
format = "??###"
first_letter: str = self.random_element(self.license_plate_old_format_first_letter)
return self.bothify(first_letter + format).upper()
def license_plate_mercosur(self) -> str:
"""Generate an new plate with Mercosur format. Since 2016"""
first_letter: str = self.random_element(self.license_plate_new_first_letter)
second_letter: str = self.random_element(self.license_plate_new_second_letter)
format = "###??"
plate = first_letter + second_letter
return self.bothify(plate + format).upper()
def license_plate(self) -> str:
"""Generate a license plate."""
return self.numerify(self.generator.parse(self.random_element(self.license_formats)))

View File

@@ -0,0 +1,64 @@
import re
from collections import OrderedDict
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``es`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Chile
"""
license_plate_old_format_first_letters = "ABCDFGHJKLPRSTVWXYZ"
license_plate_old_format_second_letters = "ABCDFGHIJKLPRSTVWXYZ"
license_plate_new_format_letters = "BCDFGHJKLPRSTVWXYZ"
license_formats = OrderedDict(
[
("{{license_plate_new}}", 0.70),
("{{license_plate_old}}", 0.20),
("{{license_plate_police}}", 0.05),
("{{license_plate_temporary}}", 0.04),
("{{license_plate_diplomatic}}", 0.01),
]
)
def license_plate_old(self) -> str:
"""Generate an old format license plate."""
format = "-####"
letters = "".join(
(
self.random_element(self.license_plate_old_format_first_letters),
self.random_element(self.license_plate_old_format_second_letters),
)
)
return self.numerify(letters + format)
def license_plate_new(self) -> str:
format = "????-##"
temp = re.sub(r"\?", lambda x: self.random_element(self.license_plate_new_format_letters), format)
return self.numerify(temp)
def license_plate_police(self) -> str:
formats = ("RP-####", "Z-####")
return self.numerify(self.random_element(formats))
def license_plate_temporary(self) -> str:
format = "PR-###"
return self.numerify(format)
def license_plate_diplomatic(self) -> str:
formats = ("CC-####", "CD-####")
return self.numerify(self.random_element(formats))
def license_plate(self) -> str:
"""Generate a license plate."""
return self.numerify(self.generator.parse(self.random_element(self.license_formats)))

View File

@@ -0,0 +1,16 @@
from collections import OrderedDict
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
license_formats = OrderedDict(
[
("???###", 0.6),
("???##?", 0.3),
("T####", 0.03),
("??####", 0.01),
("R#####", 0.03),
("S#####", 0.03),
]
)

View File

@@ -0,0 +1,124 @@
import re
from typing import Optional
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``es_ES`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Spain
.. |license_plate_unified| replace::
:meth:`license_plate_unified() <faker.providers.automotive.es_ES.Provider.license_plate_unified>`
.. |license_plate_by_province| replace::
:meth:`license_plate_by_province() <faker.providers.automotive.es_ES.Provider.license_plate_by_province>`
"""
license_formats = (
# New format
"#### ???",
)
# New format suffix letters (excluding vocals and Q from ascii uppercase)
license_plate_new_format_suffix_letters = "BCDFGHJKLMNPRSTVWXYZ"
# Old format suffix letters (excluding Q and R from ascii uppercase)
license_plate_old_format_suffix_letters = "ABCDEFGHIJKLMNOPSTUVWXYZ"
# Province prefixes (for old format)
province_prefix = (
"A", # Alicante
"AB", # Albacete
"AL", # Almería
"AV", # Ávila
"B", # Barcelona
"BA", # Badajoz
"BI", # Bilbao
"BU", # Burgos
"C", # La Coruña
"CA", # Cádiz
"CC", # Cáceres
"CS", # Castellón de la Plana
"CE", # Ceuta
"CO", # Córdoba
"CR", # Ciudad Real
"CU", # Cuenca
"GC", # Las Palmas (Gran Canaria)
"GE", # Girona (until 1992)
"GI", # Girona (since 1992)
"GR", # Granada
"GU", # Guadalajara
"H", # Huelva
"HU", # Huesca
"PM", # Palma de Mallorca (until 1997)
"IB", # Islas Baleares (since 1997)
"J", # Jaén
"L", # Lleida
"LE", # León
"LO", # Logroño
"LU", # Lugo
"M", # Madrid
"MA", # Málaga
"ML", # Melilla
"MU", # Murcia
"O", # Oviedo
"OR", # Ourense (until 1998)
"OU", # Ourense (since 1998)
"P", # Palencia
"NA", # Navarra
"PO", # Pontevedra
"S", # Santander
"SA", # Salamanca
"SE", # Sevilla
"SG", # Segovia
"SO", # Soria
"SS", # Donostia/San Sebastián
"T", # Tarragona
"TE", # Teruel
"TF", # Santa Cruz de Tenerife
"TO", # Toledo
"V", # Valencia
"VA", # Valladolid
"VI", # Vitoria
"Z", # Zaragoza
"ZA", # Zamora
)
def license_plate_unified(self) -> str:
"""Generate a unified license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.license_plate_new_format_suffix_letters),
self.license_formats[0],
)
return self.numerify(temp)
def license_plate_by_province(self, province_prefix: Optional[str] = None) -> str:
"""Generate a provincial license plate.
If a value for ``province_prefix`` is provided, the value will be used
as the prefix regardless of validity. If ``None``, then a valid prefix
will be selected at random.
"""
province_prefix = province_prefix if province_prefix is not None else self.random_element(self.province_prefix)
temp = re.sub(
r"\?",
lambda x: self.random_element(self.license_plate_old_format_suffix_letters),
"#### ??",
)
return province_prefix + " " + self.numerify(temp)
def license_plate(self) -> str:
"""Generate a license plate.
This method randomly chooses (50/50) between |license_plate_unified|
or |license_plate_by_province| to generate the result.
"""
if self.generator.random.randint(0, 1):
return self.license_plate_unified()
return self.license_plate_by_province()

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``et_EE`` locale.
Source:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Estonia
"""
license_formats = ("### ???",)

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``fi_FI`` locale.
Source:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Finland
"""
license_formats = ("???-###",)

View File

@@ -0,0 +1,10 @@
from ..en_PH import Provider as EnPhAutomotiveProvider
class Provider(EnPhAutomotiveProvider):
"""Implement automotive provider for ``fil_PH`` locale.
There is no difference from the ``en_PH`` implementation.
"""
pass

View File

@@ -0,0 +1,5 @@
from ..ar_DZ import Provider as ArDzAutomotiveProvider
class Provider(ArDzAutomotiveProvider):
pass

View File

@@ -0,0 +1,17 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``fr_FR`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France
"""
license_formats = (
# New format
"??-###-??",
# Old format for plates < 2009
"###-???-##",
)

View File

@@ -0,0 +1,11 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``he_IL`` locale."""
""" Source : https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Israel """
license_formats = (
"###-##-###",
"##-###-##",
)

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``hu_HU`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Hungary
"""
license_formats = ("???-###",)

View File

@@ -0,0 +1,16 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``id_ID`` locale."""
license_formats = (
"? ### ??",
"? ### ???",
"?? ### ??",
"?? ### ???",
"? #### ??",
"? #### ???",
"?? #### ??",
"?? #### ???",
)

View File

@@ -0,0 +1,15 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``it_IT`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Italy
"""
license_formats = (
# 1994-present
"??###??",
)

View File

@@ -0,0 +1,116 @@
from .. import Provider as AutomotiveProvider
# flake8: noqa: E501
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ja_JP`` locale.
Sources (retrieved on 2025-09-15):
- https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E3%83%8A%E3%83%B3%E3%83%90%E3%83%BC%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E4%B8%80%E8%A6%A7
- http://nplate.cloudfree.jp/misc/m50_bango.html
"""
license_plate_area_names = (
"品川",
"足立",
"練馬",
"横浜",
"川崎",
"名古屋",
"大阪",
"神戸",
"福岡",
"札幌",
"尾張小牧",
"伊勢志摩",
)
classification_numbers = (
"###",
"##",
)
license_plate_kana = (
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
)
serial_number_formats = ("#", "##", "###", "####")
MIDDLE_DOT = ""
DELIMITER = "-"
license_plate_formats = ("{{area_name}} {{classification_number}} {{kana}} {{serial_number}}",)
def license_plate(self) -> str:
"""Generate a Japanese license plate."""
pattern = self.random_element(self.license_plate_formats)
return self.generator.parse(pattern)
def area_name(self) -> str:
return self.random_element(self.license_plate_area_names)
def classification_number(self) -> str:
return self.numerify(self.random_element(self.classification_numbers))
def kana(self) -> str:
return self.random_element(self.license_plate_kana)
def serial_number(self) -> str:
"""
Generate the vehicles serial number (the last four digits on a Japanese license plate).
- For 4 digits: insert a hyphen between the second and third digits (e.g., 12-34).
- For 1 to 3 digits: pad the left side with middle dots (・) so the total width is four
characters (e.g., ・123, ・・12, ・・・1). Do not use a hyphen in these cases.
"""
raw_digits = self.numerify(self.random_element(self.serial_number_formats))
n = len(raw_digits)
if n == 4:
v = f"{raw_digits[:2]}{self.DELIMITER}{raw_digits[2:]}"
return v
else:
return raw_digits.rjust(4, self.MIDDLE_DOT)

View File

@@ -0,0 +1,52 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""
Implement automotive provider for ``ko_KR`` locale.
"""
license_formats = (
"##?####",
"###?####",
)
letter_codes = (
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
)
def license_plate(self) -> str:
pattern = self.random_element(self.license_formats)
letters = "".join(self.letter_codes)
return self.numerify(self.lexify(pattern, letters=letters))

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``lt_LT`` locale.
Source:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Lithuania
"""
license_formats = ("??? ###",)

View File

@@ -0,0 +1,16 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for `nl_BE` locale.
https://nl.wikipedia.org/wiki/Belgisch_kenteken
"""
license_formats = (
"???-###", # 1973-2008
"###-???", # 2008-2010
# New formats after 2010
"1-???-###",
"2-???-###",
)

View File

@@ -0,0 +1,77 @@
import re
import string
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for `nl_NL` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_Netherlands
- https://www.cbs.nl/en-gb/figures/detail/82044eng
.. |license_plate_car| replace::
:meth:`license_plate_car() <faker.providers.automotive.nl_NL.Provider.license_plate_car>`
.. |license_plate_motorbike| replace::
:meth:`license_plate_motorbike() <faker.providers.automotive.nl_NL.Provider.license_plate_motorbike>`
"""
# License formats for cars / other vehicles than motorbikes
license_formats = (
# Format 6
"##-%?-??",
# Format 7
"##-%??-#",
# Format 8
"#-@??-##",
# Format 9
"%?-###-?",
# Format 10
"%-###-??",
)
# License formats for motorbikes.
# According to CBS, approximately 10% of road vehicles in the Netherlands are motorbikes
license_formats_motorbike = (
"M?-??-##",
"##-M?-??",
)
# Base first letters of format
license_plate_prefix_letters = "BDFGHJKLNPRSTVXZ"
# For Format 8 (9-XXX-99) "BDFGHJLNPR" are not used,
# as to not clash with former export license plates
license_plate_prefix_letters_format_8 = "KSTVXZ"
def license_plate_motorbike(self) -> str:
"""Generate a license plate for motorbikes."""
return self.bothify(
self.random_element(self.license_formats_motorbike),
letters=string.ascii_uppercase,
)
def license_plate_car(self) -> str:
"""Generate a license plate for cars."""
# Replace % with license_plate_prefix_letters
temp = re.sub(
r"\%",
self.random_element(self.license_plate_prefix_letters),
self.random_element(self.license_formats),
)
# Replace @ with license_plate_prefix_letters_format_8
temp = re.sub(r"\@", self.random_element(self.license_plate_prefix_letters_format_8), temp)
return self.bothify(temp, letters=string.ascii_uppercase)
def license_plate(self) -> str:
"""Generate a license plate.
This method randomly chooses 10% between |license_plate_motorbike|
or 90% |license_plate_car| to generate the result.
"""
if self.generator.random.random() < 0.1:
return self.license_plate_motorbike()
return self.license_plate_car()

View File

@@ -0,0 +1,15 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``hu_HU`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Norway
"""
license_formats = (
# Classic format
"?? #####",
)

View File

@@ -0,0 +1,39 @@
from typing import List
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``pl_PL`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Poland
"""
license_formats = (
"?? #####",
"?? ####?",
"?? ###??",
"?? #?###",
"?? #??##",
"??? ?###",
"??? ##??",
"??? #?##",
"??? ##?#",
"??? #??#",
"??? ??##",
"??? #####",
"??? ####?",
"??? ###??",
)
def license_plate_regex_formats(self) -> List[str]:
"""Return a regex for matching license plates.
.. warning::
This is technically not a method that generates fake data, and it
should not be part of the public API. User should refrain from using
this method.
"""
return [plate.replace("?", "[A-Z]").replace("#", "[0-9]") for plate in self.license_formats]

View File

@@ -0,0 +1,7 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``pt_BR`` locale."""
license_formats = ("???-#?##",)

View File

@@ -0,0 +1,18 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``pt_PT`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Portugal
"""
license_formats = (
"##-##-??",
"##-??-##",
"??-##-##",
# New format since March 2020
"??-##-??",
)

View File

@@ -0,0 +1,66 @@
import string
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ro_RO`` locale."""
license_plate_prefix = (
"AB",
"AG",
"AR",
"B",
"BC",
"BH",
"BN",
"BR",
"BT",
"BV",
"BZ",
"CJ",
"CL",
"CS",
"CT",
"CV",
"DB",
"DJ",
"GJ",
"GL",
"GR",
"HD",
"HR",
"IF",
"IL",
"IS",
"MH",
"MM",
"MS",
"NT",
"OT",
"PH",
"SB",
"SJ",
"SM",
"SV",
"TL",
"TM",
"TR",
"VL",
"VN",
"VS",
)
license_plate_suffix = (
"-###-???",
"-##-???",
)
def license_plate(self) -> str:
"""Generate a license plate."""
prefix: str = self.random_element(self.license_plate_prefix)
suffix = self.bothify(
self.random_element(self.license_plate_suffix),
letters=string.ascii_uppercase,
)
return prefix + suffix

View File

@@ -0,0 +1,321 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``ru_RU`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Russia
- https://ru.wikipedia.org/wiki/Категории_транспортных_средств
"""
license_plate_letters = ("A", "B", "E", "K", "M", "Н", "О", "Р", "С", "Т", "У", "Х")
vehicle_categories = (
"M",
"A",
"A1",
"B",
"B1",
"BE",
"C",
"C1",
"C1E",
"CE",
"D",
"D1",
"DE",
"Tm",
"Tb",
)
license_plate_suffix = (
# Republic of Adygea
"01",
# Republic of Bashkortostan
"02",
"102",
# Republic of Buryatia
"03",
# Altai Republic
"04",
# Republic of Dagestan
"05",
# Republic of Ingushetia
"06",
# Kabardino-Balkar Republic
"07",
# Republic of Kalmykia
"08",
# Karachay-Cherkess Republic
"09",
# Republic of Karelia
"10",
# Komi Republic
"11",
# Mari El Republic
"12",
# Republic of Mordovia
"13",
"113",
# Sakha Republic
"14",
# Republic of North OssetiaAlania
"15",
# Republic of Tatarstan
"16",
"116",
"716",
# Tuva Republic
"17",
# Udmurt Republic
"18",
# Republic of Khakassia
"19",
# Chechen Republic
"20",
"95",
# Chuvash Republic
"21",
"121",
# Altai Krai
"22",
# Krasnodar Krai
"23",
"93",
"123",
# Krasnoyarsk Krai
"24",
"84",
"88",
"124",
# Primorsky Krai
"25",
"125",
# Stavropol Krai
"26",
"126",
# Khabarovsk Krai
"27",
# Amur Oblast
"28",
# Arkhangelsk Oblast
"29",
# Astrakhan Oblast
"30",
# Belgorod Oblast
"31",
# Bryansk Oblast
"32",
# Vladimir Oblast
"33",
# Volgograd Oblast
"34",
"134",
# Vologda Oblast
"35",
# Voronezh Oblast
"36",
"136",
# Ivanovo Oblast
"37",
# Irkutsk Oblast
"38",
"85",
"38",
# Kaliningrad Oblast
"39",
"91",
# Kaluga Oblast
"40",
# Kamchatka Krai
"41",
"82",
# Kemerovo Oblast
"42",
"142",
# Kirov Oblast
"43",
# Kostroma Oblast
"44",
# Kurgan Oblast
"45",
# Kursk Oblast
"46",
# Leningrad Oblast
"47",
# Lipetsk Oblast
"48",
# Magadan Oblast
"49",
# Moscow Oblast
"50",
"90",
"150",
"190",
"750",
# Murmansk Oblast
"51",
# Nizhny Novgorod Oblast
"52",
"152",
# Novgorod Oblast
"53",
# Novosibirsk Oblast
"54",
"154",
# Omsk Oblast
"55",
# Orenburg Oblast
"56",
# Oryol Oblast
"57",
# Penza Oblast
"58",
# Perm Krai
"59",
"81",
"159",
# Pskov Oblast
"60",
# Rostov Oblast
"61",
"161",
# Ryazan Oblast
"62",
# Samara Oblast
"63",
"163",
"763",
# Saratov Oblast
"64",
"164",
# Sakhalin Oblast
"65",
# Sverdlovsk Oblast
"66",
"96",
"196",
# Smolensk Oblast
"67",
# Tambov Oblast
"68",
# Tver Oblast
"69",
# Tomsk Oblast
"70",
# Tula Oblast
"71",
# Tyumen Oblast
"72",
# Ulyanovsk Oblast
"73",
"173",
# Chelyabinsk Oblast
"74",
"174",
# Zabaykalsky Krai
"75",
"80",
# Yaroslavl Oblast
"76",
# Moscow
"77",
"97",
"99",
"177",
"197",
"199",
"777",
"799",
# St. Petersburg
"78",
"98",
"178",
"198",
# Jewish Autonomous Oblast
"79",
# Agin-Buryat Okrug / "Former Buryat Autonomous District of Aginskoye"
"80",
# Komi-Permyak Okrug / "Former Komi-Permyak Autonomous District"
"81",
# Republic of Crimea / De jure part of Ukraine as Autonomous Republic. Annexed by Russia in 2014.
"82",
# Koryak Okrug / "Former Koryak Autonomous District"
"82",
# Nenets Autonomous Okrug (Nenetsia)
"83",
# Taymyr Autonomous Okrug / "Former Taymyr (Dolgan-Nenets) Autonomous District"
"84",
# Ust-Orda Buryat Okrug / "Former Buryat Autonomous District of Ust-Ordynskoy"
"85",
# Khanty-Mansi Autonomous Okrug
"86",
"186",
# Chukotka Autonomous Okrug
"87",
# Evenk Autonomous Okrug / "Former Evenk Autonomous District"
"88",
# Yamalo-Nenets Autonomous Okrug
"89",
# Sevastopol / De jure part of Ukraine as City with special status. Annexed by Russia in 2014.
"92",
# Territories outside of the Russian Federation,
# served by the bodies of internal affairs of the Russian Federation, such as Baikonur
"94",
)
license_plate_formats = (
# Private vehicle plate
"{{plate_letter}}{{plate_number}}{{plate_letter}}{{plate_letter}} {{plate_suffix}}",
# Public transport plate
"{{plate_letter}}{{plate_letter}}{{plate_number}} {{plate_suffix}}",
# Trailer plate
"{{plate_letter}}{{plate_letter}}{{plate_number_extra}} {{plate_suffix}}",
# Police forces vehicle plate
"{{plate_letter}}{{plate_number_extra}} {{plate_suffix}}",
# Military vehicle plate
"{{plate_number_extra}}{{plate_letter}}{{plate_letter}} {{plate_suffix}}",
# Diplomatic vehicles
"{{plate_number_special}} {{plate_suffix}}",
)
plate_number_formats = ("###",)
plate_extra_formats = ("####",)
plate_special_formats = (
"00#CD#",
"00#D###",
"00#T###",
)
def license_plate(self) -> str:
"""Generate a license plate."""
pattern: str = self.random_element(self.license_plate_formats)
return self.generator.parse(pattern)
def plate_letter(self) -> str:
"""Generate a letter for license plates."""
return self.random_element(self.license_plate_letters)
def plate_number(self) -> str:
"""Generate a number for license plates."""
return self.numerify(self.random_element(self.plate_number_formats))
def plate_number_extra(self) -> str:
"""Generate extra numerical code for license plates."""
return self.numerify(self.random_element(self.plate_extra_formats))
def plate_number_special(self) -> str:
"""Generate a special code for license plates."""
return self.numerify(self.random_element(self.plate_special_formats))
def plate_suffix(self) -> str:
"""Generate a suffix code for license plates."""
return self.random_element(self.license_plate_suffix)
def vehicle_category(self) -> str:
"""Generate a vehicle category code for license plates."""
return self.random_element(self.vehicle_categories)

View File

@@ -0,0 +1,100 @@
import string
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``sk_SK`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Slovakia
"""
license_plate_prefix = [
"BA",
"BL",
"BT", # Bratislava
"BB", # Banska Bystrica
"BJ", # Bardejov
"BN", # Banovce nad Bebravou
"BR", # Brezno
"BS", # Banska Stiavnica
"BY", # Bytca
"CA", # Cadca
"DK", # Dolny Kubin
"DS", # Dunajska Streda
"DT", # Detva
"GA", # Galanta
"GL", # Gelnica
"HC", # Hlohovec
"HE", # Humenne
"IL", # Ilava
"KA", # Krupina
"KE", # Kosice
"KK", # Kezmarok
"KM", # Kysucke Nove Mesto
"KN", # Komarno
"KS", # Kosice-okolie
"LC", # Lucenec
"LE", # Levoca
"LM", # Liptovsky Mikulas
"LV", # Levice
"MA", # Malacky
"MI", # Michalovce
"ML", # Medzilaborce
"MT", # Martin
"MY", # Myjava
"NR", # Nitra
"NM", # Nove Mesto nad Vahom
"NO", # Namestovo
"NZ", # Nove Zamky
"PB", # Povazska Bystrica
"PD", # Prievidza
"PE", # Partizanske
"PK", # Pezinok
"PN", # Piestany
"PO", # Presov
"PP", # Poprad
"PT", # Poltar
"PU", # Puchov
"RA", # Revuca
"RK", # Ruzomberok
"RS", # Rimavska Sobota
"RV", # Roznava
"SA", # Sala
"SB", # Sabinov
"SC", # Senec
"SE", # Senica
"SI", # Skalica
"SK", # Svidnik
"SL", # Stara Lubovna
"SN", # Spisska Nova Ves
"SO", # Sobrance
"SP", # Stropkov
"SV", # Snina
"TT", # Trnava
"TN", # Trencin
"TO", # Topolcany
"TR", # Turcianske Teplice
"TS", # Tvrdosin
"TV", # Trebisov
"VK", # Velky Krtis
"VT", # Vranov nad Toplou
"ZA", # Zilina
"ZC", # Zarnovica
"ZH", # Ziar nad Hronom
"ZM", # Zlate Moravce
"ZV", # Zvolen
]
license_plate_suffix = ("###??",)
def license_plate(self) -> str:
"""Generate a license plate."""
prefix: str = self.random_element(self.license_plate_prefix)
suffix = self.bothify(
self.random_element(self.license_plate_suffix),
letters=string.ascii_uppercase,
)
return prefix + suffix

View File

@@ -0,0 +1,12 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``sq_AL`` locale.
Source:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Albania
"""
license_formats = ("?? ###??",)

View File

@@ -0,0 +1,18 @@
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``sv_SE`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Sweden
- https://www.transportstyrelsen.se/en/road/Vehicles/license-plates/
"""
license_formats = (
# Classic format
"??? ###",
# New format
"??? ##?",
)

View File

@@ -0,0 +1,39 @@
import re
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``th_TH`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Thailand
"""
license_formats = (
"# ?? ####",
"# ?? ###",
"# ?? ##",
"# ?? #",
"?? ####",
"?? ###",
"?? ##",
"?? #",
"??? ###",
"??? ##",
"??? #",
"##-####",
)
thai_consonants = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ"
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.thai_consonants),
self.random_element(self.license_formats),
)
return self.numerify(temp)

View File

@@ -0,0 +1,10 @@
from ..en_PH import Provider as EnPhAutomotiveProvider
class Provider(EnPhAutomotiveProvider):
"""Implement automotive provider for ``tl_PH`` locale.
There is no difference from the ``en_PH`` implementation.
"""
pass

View File

@@ -0,0 +1,33 @@
import re
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``tr_TR`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Turkey
"""
license_formats = (
"## ? ####",
"## ? #####",
"## ?? ###",
"## ?? ####",
"## ??? ##",
"## ??? ###",
)
ascii_uppercase_turkish = "ABCDEFGHIJKLMNOPRSTUVYZ"
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.ascii_uppercase_turkish),
self.random_element(self.license_formats),
)
temp = temp.replace("##", "{:02d}", 1)
temp = temp.format(self.random_element(range(1, 82)))
return self.numerify(temp)

View File

@@ -0,0 +1,291 @@
import random
from typing import Optional, Tuple
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
plate_number_formats = ("####",)
license_region_data = {
"Crimea": (("AK", "KK", "TK", "MK"), "01"),
"Kyiv": (("AA", "KA", "TT", "TA"), "11"),
"Vinnytsia": (("AB", "KB", "MM", "OK"), "02"),
"Volyn": (("AC", "KC", "SM", "TS"), "03"),
"Dnipro": (("AE", "KE", "RR", "MI"), "04"),
"Donetsk": (("AN", "KH", "TM", "MH"), "05"),
"Kyiv_reg": (("AI", "KI", "TI", "ME"), "10"),
"Zhytomyr": (("AM", "KM", "TM", "MV"), "06"),
"Zakarpattia": (("AO", "KO", "MT", "MO"), "07"),
"Zaporizhzhia": (("AR", "KR", "TR", "MR"), "08"),
"IvanoFrankivsk": (("AT", "KT", "TO", "XS"), "09"),
"Kirovohrad": (("BA", "NA", "XA", "EA"), "12"),
"Luhansk": (("BB", "NV", "EE", "EV"), "13"),
"Lviv": (("BS", "NS", "SS", "ES"), "14"),
"Mykolaiv": (("BE", "NE", "XE", "XN"), "15"),
"Odesa": (("BN", "NN", "OO", "EN"), "16"),
"Poltava": (("BI", "NI", "XI", "EI"), "17"),
"Rivne": (("BK", "NK", "XK", "EK"), "18"),
"Sumy": (("BM", "NM", "XM", "EM"), "19"),
"Ternopil": (("BO", "NO", "XO", "EO"), "20"),
"Kharkiv": (("AX", "KX", "XX", "EX"), "21"),
"Kherson": (("BT", "NT", "XT", "ET"), "22"),
"Khmelnytskyi": (("BX", "NX", "OX", "RX"), "23"),
"Cherkasy": (("SA", "IA", "OA", "RA"), "24"),
"Chernihiv": (("SV", "IV", "OV", "RV"), "25"),
"Chernivtsi": (("SE", "IE", "OE", "RE"), "26"),
"Sevastopol": (("SN", "IN", "ON", "RN"), "27"),
"Nationwide": (("II", "ED", "DC", "DI", "PD"), "00"),
}
license_plate_suffix = (
"AA",
"BA",
"CA",
"EA",
"HA",
"IA",
"KA",
"MA",
"OA",
"PA",
"TA",
"XA",
"AB",
"BB",
"CB",
"EB",
"HB",
"IB",
"KB",
"MB",
"OB",
"PB",
"TB",
"XB",
"AC",
"BC",
"BR",
"EC",
"HC",
"IC",
"KC",
"MC",
"OC",
"PC",
"TC",
"XC",
"AE",
"BE",
"CE",
"EE",
"HE",
"IE",
"KE",
"ME",
"OE",
"PE",
"TE",
"XE",
"AN",
"BN",
"CN",
"EN",
"HN",
"IN",
"KN",
"MK",
"ON",
"PN",
"TN",
"XN",
"AI",
"BI",
"CI",
"EI",
"HI",
"II",
"KI",
"MI",
"OI",
"PI",
"TI",
"XI",
"AK",
"BK",
"CK",
"EK",
"HK",
"IK",
"KK",
"MK",
"OK",
"PK",
"TK",
"XK",
"AM",
"BM",
"CM",
"EM",
"HM",
"IM",
"KM",
"MM",
"OM",
"PM",
"TM",
"XM",
"AO",
"BO",
"CO",
"EO",
"HO",
"IO",
"KO",
"MO",
"OO",
"PO",
"TO",
"XO",
"AP",
"BP",
"CP",
"EP",
"HP",
"IP",
"KP",
"MP",
"OP",
"PP",
"TP",
"XP",
"AT",
"BT",
"CT",
"ET",
"HT",
"IT",
"KT",
"MT",
"OT",
"PT",
"TT",
"XT",
"AX",
"BX",
"CX",
"EX",
"HX",
"IX",
"KX",
"MX",
"OX",
"PX",
"TX",
"XX",
"AY",
"AZ",
"BH",
"BL",
"BN",
"BQ",
"BR",
"TU",
"TV",
"TY",
"TZ",
)
vehicle_categories = ("A1", "A", "B1", "B", "C1", "C", "D1", "D", "BE", "C1E", "CE", "D1E", "DE", "T")
def __get_random_region_code(self, region_name: Optional[str] = None) -> Tuple[str, str]:
try:
if region_name is None:
region_name, _ = random.choice(list(self.license_region_data.items()))
prefix, region_number = self.license_region_data[region_name]
return random.choice(prefix), region_number
except KeyError:
region_names = ", ".join(self.license_region_data.keys())
raise KeyError(f"Keys name must be only {region_names}")
def license_plate(self, region_name: Optional[str] = None, temporary_plate: bool = False) -> str:
"""Generate a license plate.
- If ``region_name`` is ``None`` (default), its value will be set to a random.
- If ``region_name`` is ``Kyiv``, will use this region in build of license plates.
- If ``temporary_plate`` is ``False`` (default), generate license plate AA0000AA format
- If ``temporary_plate`` is ``True``, generate temporary plate format 01 AA0000
- 01 - 27 it's region number
:sample:
:sample: region_name=None, temporary_plate=False
:sample: region_name=None, temporary_plate=True
:sample: region_name="Kyiv", temporary_plate=False
:sample: region_name="Kyiv", temporary_plate=True
"""
region, region_number = self.__get_random_region_code(region_name)
if temporary_plate:
return f"{region_number} {region}{self.plate_number()}"
number = self.plate_number()
series = self.plate_letter_suffix()
return f"{region}{number}{series}"
def plate_region_code(self, region_name: Optional[str] = None) -> str:
"""
Generate plate region number
:sample:
:sample: region_name="Kyiv"
"""
_, region_number = self.__get_random_region_code(region_name)
return region_number
def plate_letter_prefix(self, region_name: Optional[str] = None) -> str:
"""
Generate a letter for license plates.
:sample:
:sample: region_name="Kyiv"
"""
letters, _ = self.__get_random_region_code(region_name)
return letters
def plate_letter_suffix(self) -> str:
"""
Generate a end letter for license plates.
:sample:
"""
return self.random_element(self.license_plate_suffix)
def plate_number(self) -> str:
"""
Generate a number for license plates.
:sample:
"""
return self.numerify(self.random_element(self.plate_number_formats))
def diplomatic_license_plate(self) -> str:
"""
Example: 'CDP 000' or 'DP 000 000' or 'S 000 000' format
:sample:
"""
level = random.choice(("CDP", "DP", "S"))
country_code = self.random_number(3, fix_len=True)
car_number = self.random_number(3, fix_len=True)
if level == "CDP":
return f"{level} {country_code}"
return f"{level} {country_code} {car_number}"
def vehicle_category(self) -> str:
"""
Generate a vehicle category code for license plates.
:sample:
"""
return self.random_element(self.vehicle_categories)

View File

@@ -0,0 +1,24 @@
import re
from .. import Provider as AutomotiveProvider
class Provider(AutomotiveProvider):
"""Implement automotive provider for ``vi_VN`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Vietnam
"""
license_formats = ("##?-#####",)
ascii_uppercase_vietnamese = "ABCDĐEFGHKLMNPSTUVXYZ"
def license_plate(self) -> str:
"""Generate a license plate."""
temp = re.sub(
r"\?",
lambda x: self.random_element(self.ascii_uppercase_vietnamese),
self.random_element(self.license_formats),
)
return self.numerify(temp)

Some files were not shown because too many files have changed in this diff Show More