From b38247990596875b083168319c371c334c933ebd Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 14:32:34 +0900 Subject: [PATCH 1/2] :bug: Fix TODO of person module --- src/faker/provider/address/address_en_US.nim | 1367 +++++++++++++++++- 1 file changed, 1350 insertions(+), 17 deletions(-) diff --git a/src/faker/provider/address/address_en_US.nim b/src/faker/provider/address/address_en_US.nim index f0b268a..4d18005 100644 --- a/src/faker/provider/address/address_en_US.nim +++ b/src/faker/provider/address/address_en_US.nim @@ -1,8 +1,1315 @@ import random, strutils from strformat import `&` +from sequtils import mapIt + +from ../person import lastName, firstName include interfaces +type + Country* = object + timezones*: seq[string] + alpha2Code, alpha3Code, continent, name, capital: string + +const + countries = @[ + Country(timezones: @["Europe/Andorra"], + alpha2Code: "AD", + alpha3Code: "AND", + continent: "Europe", + name: "Andorra", + capital: "Andorra la Vella"), + Country(timezones: @["Asia/Kabul"], + alpha2Code: "AF", + alpha3Code: "AFG", + continent: "Asia", + name: "Afghanistan", + capital: "Kabul"), + Country(timezones: @["America/Antigua"], + alpha2Code: "AG", + alpha3Code: "ATG", + continent: "North America", + name: "Antigua and Barbuda", + capital: "St. John's"), + Country(timezones: @["Europe/Tirane"], + alpha2Code: "AL", + alpha3Code: "ALB", + continent: "Europe", + name: "Albania", + capital: "Tirana"), + Country(timezones: @["Asia/Yerevan"], + alpha2Code: "AM", + alpha3Code: "ARM", + continent: "Asia", + name: "Armenia", + capital: "Yerevan"), + Country(timezones: @["Africa/Luanda"], + alpha2Code: "AO", + alpha3Code: "AGO", + continent: "Africa", + name: "Angola", + capital: "Luanda"), + Country(timezones: @["America/Argentina/Buenos_Aires", + "America/Argentina/Cordoba", + "America/Argentina/Jujuy", + "America/Argentina/Tucuman", + "America/Argentina/Catamarca", + "America/Argentina/La_Rioja", + "America/Argentina/San_Juan", + "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", + "America/Argentina/Ushuaia"], + alpha2Code: "AR", + alpha3Code: "ARG", + continent: "South America", + name: "Argentina", + capital: "Buenos Aires"), + Country(timezones: @["Europe/Vienna"], + alpha2Code: "AT", + alpha3Code: "AUT", + continent: "Europe", + name: "Austria", + capital: "Vienna"), + Country(timezones: @["Australia/Lord_Howe", + "Australia/Hobart", + "Australia/Currie", + "Australia/Melbourne", + "Australia/Sydney", + "Australia/Broken_Hill", + "Australia/Brisbane", + "Australia/Lindeman", + "Australia/Adelaide", + "Australia/Darwin", + "Australia/Perth"], + alpha2Code: "AU", + alpha3Code: "AUS", + continent: "Oceania", + name: "Australia", + capital: "Canberra"), + Country(timezones: @["Asia/Baku"], + alpha2Code: "AZ", + alpha3Code: "AZE", + continent: "Asia", + name: "Azerbaijan", + capital: "Baku"), + Country(timezones: @["America/Barbados"], + alpha2Code: "BB", + alpha3Code: "BRB", + continent: "North America", + name: "Barbados", + capital: "Bridgetown"), + Country(timezones: @["Asia/Dhaka"], + alpha2Code: "BD", + alpha3Code: "BGD", + continent: "Asia", + name: "Bangladesh", + capital: "Dhaka"), + Country(timezones: @["Europe/Brussels"], + alpha2Code: "BE", + alpha3Code: "BEL", + continent: "Europe", + name: "Belgium", + capital: "Brussels"), + Country(timezones: @["Africa/Ouagadougou"], + alpha2Code: "BF", + alpha3Code: "BFA", + continent: "Africa", + name: "Burkina Faso", + capital: "Ouagadougou"), + Country(timezones: @["Europe/Sofia"], + alpha2Code: "BG", + alpha3Code: "BGR", + continent: "Europe", + name: "Bulgaria", + capital: "Sofia"), + Country(timezones: @["Asia/Bahrain"], + alpha2Code: "BH", + alpha3Code: "BHR", + continent: "Asia", + name: "Bahrain", + capital: "Manama"), + Country(timezones: @["Africa/Bujumbura"], + alpha2Code: "BI", + alpha3Code: "BDI", + continent: "Africa", + name: "Burundi", + capital: "Bujumbura"), + Country(timezones: @["Africa/Porto-Novo"], + alpha2Code: "BJ", + alpha3Code: "BEN", + continent: "Africa", + name: "Benin", + capital: "Porto-Novo"), + Country(timezones: @["Asia/Brunei"], + alpha2Code: "BN", + alpha3Code: "BRN", + continent: "Asia", + name: "Brunei Darussalam", + capital: "Bandar Seri Begawan"), + Country(timezones: @["America/La_Paz"], + alpha2Code: "BO", + alpha3Code: "BOL", + continent: "South America", + name: "Bolivia", + capital: "Sucre"), + Country(timezones: @["America/Noronha", + "America/Belem", + "America/Fortaleza", + "America/Recife", + "America/Araguaina", + "America/Maceio", + "America/Bahia", + "America/Sao_Paulo", + "America/Campo_Grande", + "America/Cuiaba", + "America/Porto_Velho", + "America/Boa_Vista", + "America/Manaus", + "America/Eirunepe", + "America/Rio_Branco"], + alpha2Code: "BR", + alpha3Code: "BRA", + continent: "South America", + name: "Brazil", + capital: "Bras\xc3\xadlia"), + Country(timezones: @["America/Nassau"], + alpha2Code: "BS", + alpha3Code: "BHS", + continent: "North America", + name: "Bahamas", + capital: "Nassau"), + Country(timezones: @["Asia/Thimphu"], + alpha2Code: "BT", + alpha3Code: "BTN", + continent: "Asia", + name: "Bhutan", + capital: "Thimphu"), + Country(timezones: @["Africa/Gaborone"], + alpha2Code: "BW", + alpha3Code: "BWA", + continent: "Africa", + name: "Botswana", + capital: "Gaborone"), + Country(timezones: @["Europe/Minsk"], + alpha2Code: "BY", + alpha3Code: "BLR", + continent: "Europe", + name: "Belarus", + capital: "Minsk"), + Country(timezones: @["America/Belize"], + alpha2Code: "BZ", + alpha3Code: "BLZ", + continent: "North America", + name: "Belize", + capital: "Belmopan"), + Country(timezones: @["America/St_Johns", + "America/Halifax", + "America/Glace_Bay", + "America/Moncton", + "America/Goose_Bay", + "America/Blanc-Sablon", + "America/Montreal", + "America/Toronto", + "America/Nipigon", + "America/Thunder_Bay", + "America/Pangnirtung", + "America/Iqaluit", + "America/Atikokan", + "America/Rankin_Inlet", + "America/Winnipeg", + "America/Rainy_River", + "America/Cambridge_Bay", + "America/Regina", + "America/Swift_Current", + "America/Edmonton", + "America/Yellowknife", + "America/Inuvik", + "America/Dawson_Creek", + "America/Vancouver", + "America/Whitehorse", + "America/Dawson"], + alpha2Code: "CA", + alpha3Code: "CAN", + continent: "North America", + name: "Canada", + capital: "Ottawa"), + Country(timezones: @["Africa/Kinshasa", + "Africa/Lubumbashi"], + alpha2Code: "CD", + alpha3Code: "COD", + continent: "Africa", + name: "Democratic Republic of the Congo", + capital: "Kinshasa"), + Country(timezones: @["Africa/Brazzaville"], + alpha2Code: "CG", + alpha3Code: "COG", + continent: "Africa", + name: "Republic of the Congo", + capital: "Brazzaville"), + Country(timezones: @["Africa/Abidjan"], + alpha2Code: "CI", + alpha3Code: "CIV", + continent: "Africa", + name: "C\xc3\xb4te d'Ivoire", + capital: "Yamoussoukro"), + Country(timezones: @["America/Santiago", + "Pacific/Easter"], + alpha2Code: "CL", + alpha3Code: "CHL", + continent: "South America", + name: "Chile", + capital: "Santiago"), + Country(timezones: @["Africa/Douala"], + alpha2Code: "CM", + alpha3Code: "CMR", + continent: "Africa", + name: "Cameroon", + capital: "Yaound\xc3\xa9"), + Country(timezones: @["Asia/Shanghai", + "Asia/Harbin", + "Asia/Chongqing", + "Asia/Urumqi", + "Asia/Kashgar"], + alpha2Code: "CN", + alpha3Code: "CHN", + continent: "Asia", + name: "People's Republic of China", + capital: "Beijing"), + Country(timezones: @["America/Bogota"], + alpha2Code: "CO", + alpha3Code: "COL", + continent: "South America", + name: "Colombia", + capital: "Bogot\xc3\xa1"), + Country(timezones: @["America/Costa_Rica"], + alpha2Code: "CR", + alpha3Code: "CRI", + continent: "North America", + name: "Costa Rica", + capital: "San Jos\xc3\xa9"), + Country(timezones: @["America/Havana"], + alpha2Code: "CU", + alpha3Code: "CUB", + continent: "North America", + name: "Cuba", + capital: "Havana"), + Country(timezones: @["Atlantic/Cape_Verde"], + alpha2Code: "CV", + alpha3Code: "CPV", + continent: "Africa", + name: "Cape Verde", + capital: "Praia"), + Country(timezones: @["Asia/Nicosia"], + alpha2Code: "CY", + alpha3Code: "CYP", + continent: "Asia", + name: "Cyprus", + capital: "Nicosia"), + Country(timezones: @["Europe/Prague"], + alpha2Code: "CZ", + alpha3Code: "CZE", + continent: "Europe", + name: "Czech Republic", + capital: "Prague"), + Country(timezones: @["Europe/Berlin"], + alpha2Code: "DE", + alpha3Code: "DEU", + continent: "Europe", + name: "Germany", + capital: "Berlin"), + Country(timezones: @["Africa/Djibouti"], + alpha2Code: "DJ", + alpha3Code: "DJI", + continent: "Africa", + name: "Djibouti", + capital: "Djibouti City"), + Country(timezones: @["Europe/Copenhagen"], + alpha2Code: "DK", + alpha3Code: "DNK", + continent: "Europe", + name: "Denmark", + capital: "Copenhagen"), + Country(timezones: @["America/Dominica"], + alpha2Code: "DM", + alpha3Code: "DMA", + continent: "North America", + name: "Dominica", + capital: "Roseau"), + Country(timezones: @["America/Santo_Domingo"], + alpha2Code: "DO", + alpha3Code: "DOM", + continent: "North America", + name: "Dominican Republic", + capital: "Santo Domingo"), + Country(timezones: @["America/Guayaquil", + "Pacific/Galapagos"], + alpha2Code: "EC", + alpha3Code: "ECU", + continent: "South America", + name: "Ecuador", + capital: "Quito"), + Country(timezones: @["Europe/Tallinn"], + alpha2Code: "EE", + alpha3Code: "EST", + continent: "Europe", + name: "Estonia", + capital: "Tallinn"), + Country(timezones: @["Africa/Cairo"], + alpha2Code: "EG", + alpha3Code: "EGY", + continent: "Africa", + name: "Egypt", + capital: "Cairo"), + Country(timezones: @["Africa/Asmera"], + alpha2Code: "ER", + alpha3Code: "ERI", + continent: "Africa", + name: "Eritrea", + capital: "Asmara"), + Country(timezones: @["Africa/Addis_Ababa"], + alpha2Code: "ET", + alpha3Code: "ETH", + continent: "Africa", + name: "Ethiopia", + capital: "Addis Ababa"), + Country(timezones: @["Europe/Helsinki"], + alpha2Code: "FI", + alpha3Code: "FIN", + continent: "Europe", + name: "Finland", + capital: "Helsinki"), + Country(timezones: @["Pacific/Fiji"], + alpha2Code: "FJ", + alpha3Code: "FJI", + continent: "Oceania", + name: "Fiji", + capital: "Suva"), + Country(timezones: @["Europe/Paris"], + alpha2Code: "FR", + alpha3Code: "FRA", + continent: "Europe", + name: "France", + capital: "Paris"), + Country(timezones: @["Africa/Libreville"], + alpha2Code: "GA", + alpha3Code: "GAB", + continent: "Africa", + name: "Gabon", + capital: "Libreville"), + Country(timezones: @["Asia/Tbilisi"], + alpha2Code: "GE", + alpha3Code: "GEO", + continent: "Asia", + name: "Georgia", + capital: "Tbilisi"), + Country(timezones: @["Africa/Accra"], + alpha2Code: "GH", + alpha3Code: "GHA", + continent: "Africa", + name: "Ghana", + capital: "Accra"), + Country(timezones: @["Africa/Banjul"], + alpha2Code: "GM", + alpha3Code: "GMB", + continent: "Africa", + name: "The Gambia", + capital: "Banjul"), + Country(timezones: @["Africa/Conakry"], + alpha2Code: "GN", + alpha3Code: "GIN", + continent: "Africa", + name: "Guinea", + capital: "Conakry"), + Country(timezones: @["Europe/Athens"], + alpha2Code: "GR", + alpha3Code: "GRC", + continent: "Europe", + name: "Greece", + capital: "Athens"), + Country(timezones: @["America/Guatemala"], + alpha2Code: "GT", + alpha3Code: "GTM", + continent: "North America", + name: "Guatemala", + capital: "Guatemala City"), + Country(timezones: @["America/Guatemala"], + alpha2Code: "HT", + alpha3Code: "HTI", + continent: "North America", + name: "Haiti", + capital: "Port-au-Prince"), + Country(timezones: @["Africa/Bissau"], + alpha2Code: "GW", + alpha3Code: "GNB", + continent: "Africa", + name: "Guinea-Bissau", + capital: "Bissau"), + Country(timezones: @["America/Guyana"], + alpha2Code: "GY", + alpha3Code: "GUY", + continent: "South America", + name: "Guyana", + capital: "Georgetown"), + Country(timezones: @["America/Tegucigalpa"], + alpha2Code: "HN", + alpha3Code: "HND", + continent: "North America", + name: "Honduras", + capital: "Tegucigalpa"), + Country(timezones: @["Europe/Budapest"], + alpha2Code: "HU", + alpha3Code: "HUN", + continent: "Europe", + name: "Hungary", + capital: "Budapest"), + Country(timezones: @["Asia/Jakarta", + "Asia/Pontianak", + "Asia/Makassar", + "Asia/Jayapura"], + alpha2Code: "ID", + alpha3Code: "IDN", + continent: "Asia", + name: "Indonesia", + capital: "Jakarta"), + Country(timezones: @["Europe/Dublin"], + alpha2Code: "IE", + alpha3Code: "IRL", + continent: "Europe", + name: "Republic of Ireland", + capital: "Dublin"), + Country(timezones: @["Asia/Jerusalem"], + alpha2Code: "IL", + alpha3Code: "ISR", + continent: "Asia", + name: "Israel", + capital: "Jerusalem"), + Country(timezones: @["Asia/Calcutta"], + alpha2Code: "IN", + alpha3Code: "IND", + continent: "Asia", + name: "India", + capital: "New Delhi"), + Country(timezones: @["Asia/Baghdad"], + alpha2Code: "IQ", + alpha3Code: "IRQ", + continent: "Asia", + name: "Iraq", + capital: "Baghdad"), + Country(timezones: @["Asia/Tehran"], + alpha2Code: "IR", + alpha3Code: "IRN", + continent: "Asia", + name: "Iran", + capital: "Tehran"), + Country(timezones: @["Atlantic/Reykjavik"], + alpha2Code: "IS", + alpha3Code: "ISL", + continent: "Europe", + name: "Iceland", + capital: "Reykjav\xc3\xadk"), + Country(timezones: @["Europe/Rome"], + alpha2Code: "IT", + alpha3Code: "ITA", + continent: "Europe", + name: "Italy", + capital: "Rome"), + Country(timezones: @["America/Jamaica"], + alpha2Code: "JM", + alpha3Code: "JAM", + continent: "North America", + name: "Jamaica", + capital: "Kingston"), + Country(timezones: @["Asia/Amman"], + alpha2Code: "JO", + alpha3Code: "JOR", + continent: "Asia", + name: "Jordan", + capital: "Amman"), + Country(timezones: @["Asia/Tokyo"], + alpha2Code: "JP", + alpha3Code: "JPN", + continent: "Asia", + name: "Japan", + capital: "Tokyo"), + Country(timezones: @["Africa/Nairobi"], + alpha2Code: "KE", + alpha3Code: "KEN", + continent: "Africa", + name: "Kenya", + capital: "Nairobi"), + Country(timezones: @["Asia/Bishkek"], + alpha2Code: "KG", + alpha3Code: "KGZ", + continent: "Asia", + name: "Kyrgyzstan", + capital: "Bishkek"), + Country(timezones: @["Pacific/Tarawa", + "Pacific/Enderbury", + "Pacific/Kiritimati"], + alpha2Code: "KI", + alpha3Code: "KIR", + continent: "Oceania", + name: "Kiribati", + capital: "Tarawa"), + Country(timezones: @["Asia/Pyongyang"], + alpha2Code: "KP", + alpha3Code: "PRK", + continent: "Asia", + name: "North Korea", + capital: "Pyongyang"), + Country(timezones: @["Asia/Seoul"], + alpha2Code: "KR", + alpha3Code: "KOR", + continent: "Asia", + name: "South Korea", + capital: "Seoul"), + Country(timezones: @["Asia/Kuwait"], + alpha2Code: "KW", + alpha3Code: "KWT", + continent: "Asia", + name: "Kuwait", + capital: "Kuwait City"), + Country(timezones: @["Asia/Beirut"], + alpha2Code: "LB", + alpha3Code: "LBN", + continent: "Asia", + name: "Lebanon", + capital: "Beirut"), + Country(timezones: @["Europe/Vaduz"], + alpha2Code: "LI", + alpha3Code: "LIE", + continent: "Europe", + name: "Liechtenstein", + capital: "Vaduz"), + Country(timezones: @["Africa/Monrovia"], + alpha2Code: "LR", + alpha3Code: "LBR", + continent: "Africa", + name: "Liberia", + capital: "Monrovia"), + Country(timezones: @["Africa/Maseru"], + alpha2Code: "LS", + alpha3Code: "LSO", + continent: "Africa", + name: "Lesotho", + capital: "Maseru"), + Country(timezones: @["Europe/Vilnius"], + alpha2Code: "LT", + alpha3Code: "LTU", + continent: "Europe", + name: "Lithuania", + capital: "Vilnius"), + Country(timezones: @["Europe/Luxembourg"], + alpha2Code: "LU", + alpha3Code: "LUX", + continent: "Europe", + name: "Luxembourg", + capital: "Luxembourg City"), + Country(timezones: @["Europe/Riga"], + alpha2Code: "LV", + alpha3Code: "LVA", + continent: "Europe", + name: "Latvia", + capital: "Riga"), + Country(timezones: @["Africa/Tripoli"], + alpha2Code: "LY", + alpha3Code: "LBY", + continent: "Africa", + name: "Libya", + capital: "Tripoli"), + Country(timezones: @["Indian/Antananarivo"], + alpha2Code: "MG", + alpha3Code: "MDG", + continent: "Africa", + name: "Madagascar", + capital: "Antananarivo"), + Country(timezones: @["Pacific/Majuro", + "Pacific/Kwajalein"], + alpha2Code: "MH", + alpha3Code: "MHL", + continent: "Oceania", + name: "Marshall Islands", + capital: "Majuro"), + Country(timezones: @["Europe/Skopje"], + alpha2Code: "MK", + alpha3Code: "MKD", + continent: "Europe", + name: "Macedonia", + capital: "Skopje"), + Country(timezones: @["Africa/Bamako"], + alpha2Code: "ML", + alpha3Code: "MLI", + continent: "Africa", + name: "Mali", + capital: "Bamako"), + Country(timezones: @["Asia/Rangoon"], + alpha2Code: "MM", + alpha3Code: "MMR", + continent: "Asia", + name: "Myanmar", + capital: "Naypyidaw"), + Country(timezones: @["Asia/Ulaanbaatar", + "Asia/Hovd", + "Asia/Choibalsan"], + alpha2Code: "MN", + alpha3Code: "MNG", + continent: "Asia", + name: "Mongolia", + capital: "Ulaanbaatar"), + Country(timezones: @["Africa/Nouakchott"], + alpha2Code: "MR", + alpha3Code: "MRT", + continent: "Africa", + name: "Mauritania", + capital: "Nouakchott"), + Country(timezones: @["Europe/Malta"], + alpha2Code: "MT", + alpha3Code: "MLT", + continent: "Europe", + name: "Malta", + capital: "Valletta"), + Country(timezones: @["Indian/Mauritius"], + alpha2Code: "MU", + alpha3Code: "MUS", + continent: "Africa", + name: "Mauritius", + capital: "Port Louis"), + Country(timezones: @["Indian/Maldives"], + alpha2Code: "MV", + alpha3Code: "MDV", + continent: "Asia", + name: "Maldives", + capital: "Mal\xc3\xa9"), + Country(timezones: @["Africa/Blantyre"], + alpha2Code: "MW", + alpha3Code: "MWI", + continent: "Africa", + name: "Malawi", + capital: "Lilongwe"), + Country(timezones: @["America/Mexico_City", + "America/Cancun", + "America/Merida", + "America/Monterrey", + "America/Mazatlan", + "America/Chihuahua", + "America/Hermosillo", + "America/Tijuana"], + alpha2Code: "MX", + alpha3Code: "MEX", + continent: "North America", + name: "Mexico", + capital: "Mexico City"), + Country(timezones: @["Asia/Kuala_Lumpur", + "Asia/Kuching"], + alpha2Code: "MY", + alpha3Code: "MYS", + continent: "Asia", + name: "Malaysia", + capital: "Kuala Lumpur"), + Country(timezones: @["Africa/Maputo"], + alpha2Code: "MZ", + alpha3Code: "MOZ", + continent: "Africa", + name: "Mozambique", + capital: "Maputo"), + Country(timezones: @["Africa/Windhoek"], + alpha2Code: "NA", + alpha3Code: "NAM", + continent: "Africa", + name: "Namibia", + capital: "Windhoek"), + Country(timezones: @["Africa/Niamey"], + alpha2Code: "NE", + alpha3Code: "NER", + continent: "Africa", + name: "Niger", + capital: "Niamey"), + Country(timezones: @["Africa/Lagos"], + alpha2Code: "NG", + alpha3Code: "NGA", + continent: "Africa", + name: "Nigeria", + capital: "Abuja"), + Country(timezones: @["America/Managua"], + alpha2Code: "NI", + alpha3Code: "NIC", + continent: "North America", + name: "Nicaragua", + capital: "Managua"), + Country(timezones: @["Europe/Amsterdam"], + alpha2Code: "NL", + alpha3Code: "NLD", + continent: "Europe", + name: "Kingdom of the Netherlands", + capital: "Amsterdam"), + Country(timezones: @["Europe/Oslo"], + alpha2Code: "NO", + alpha3Code: "NOR", + continent: "Europe", + name: "Norway", + capital: "Oslo"), + Country(timezones: @["Asia/Katmandu"], + alpha2Code: "NP", + alpha3Code: "NPL", + continent: "Asia", + name: "Nepal", + capital: "Kathmandu"), + Country(timezones: @["Pacific/Nauru"], + alpha2Code: "NR", + alpha3Code: "NRU", + continent: "Oceania", + name: "Nauru", + capital: "Yaren"), + Country(timezones: @["Pacific/Auckland", + "Pacific/Chatham"], + alpha2Code: "NZ", + alpha3Code: "NZL", + continent: "Oceania", + name: "New Zealand", + capital: "Wellington"), + Country(timezones: @["Asia/Muscat"], + alpha2Code: "OM", + alpha3Code: "OMN", + continent: "Asia", + name: "Oman", + capital: "Muscat"), + Country(timezones: @["America/Panama"], + alpha2Code: "PA", + alpha3Code: "PAN", + continent: "North America", + name: "Panama", + capital: "Panama City"), + Country(timezones: @["America/Lima"], + alpha2Code: "PE", + alpha3Code: "PER", + continent: "South America", + name: "Peru", + capital: "Lima"), + Country(timezones: @["Pacific/Port_Moresby"], + alpha2Code: "PG", + alpha3Code: "PNG", + continent: "Oceania", + name: "Papua New Guinea", + capital: "Port Moresby"), + Country(timezones: @["Asia/Manila"], + alpha2Code: "PH", + alpha3Code: "PHL", + continent: "Asia", + name: "Philippines", + capital: "Manila"), + Country(timezones: @["Asia/Karachi"], + alpha2Code: "PK", + alpha3Code: "PAK", + continent: "Asia", + name: "Pakistan", + capital: "Islamabad"), + Country(timezones: @["Europe/Warsaw"], + alpha2Code: "PL", + alpha3Code: "POL", + continent: "Europe", + name: "Poland", + capital: "Warsaw"), + Country(timezones: @["Europe/Lisbon", + "Atlantic/Madeira", + "Atlantic/Azores"], + alpha2Code: "PT", + alpha3Code: "PRT", + continent: "Europe", + name: "Portugal", + capital: "Lisbon"), + Country(timezones: @["Pacific/Palau"], + alpha2Code: "PW", + alpha3Code: "PLW", + continent: "Oceania", + name: "Palau", + capital: "Ngerulmud"), + Country(timezones: @["America/Asuncion"], + alpha2Code: "PY", + alpha3Code: "PRY", + continent: "South America", + name: "Paraguay", + capital: "Asunci\xc3\xb3n"), + Country(timezones: @["Asia/Qatar"], + alpha2Code: "QA", + alpha3Code: "QAT", + continent: "Asia", + name: "Qatar", + capital: "Doha"), + Country(timezones: @["Europe/Bucharest"], + alpha2Code: "RO", + alpha3Code: "ROU", + continent: "Europe", + name: "Romania", + capital: "Bucharest"), + Country(timezones: @["Europe/Kaliningrad", + "Europe/Moscow", + "Europe/Volgograd", + "Europe/Samara", + "Asia/Yekaterinburg", + "Asia/Omsk", + "Asia/Novosibirsk", + "Asia/Krasnoyarsk", + "Asia/Irkutsk", + "Asia/Yakutsk", + "Asia/Vladivostok", + "Asia/Sakhalin", + "Asia/Magadan", + "Asia/Kamchatka", + "Asia/Anadyr"], + alpha2Code: "RU", + alpha3Code: "RUS", + continent: "Europe", + name: "Russia", + capital: "Moscow"), + Country(timezones: @["Africa/Kigali"], + alpha2Code: "RW", + alpha3Code: "RWA", + continent: "Africa", + name: "Rwanda", + capital: "Kigali"), + Country(timezones: @["Asia/Riyadh"], + alpha2Code: "SA", + alpha3Code: "SAU", + continent: "Asia", + name: "Saudi Arabia", + capital: "Riyadh"), + Country(timezones: @["Pacific/Guadalcanal"], + alpha2Code: "SB", + alpha3Code: "SLB", + continent: "Oceania", + name: "Solomon Islands", + capital: "Honiara"), + Country(timezones: @["Indian/Mahe"], + alpha2Code: "SC", + alpha3Code: "SYC", + continent: "Africa", + name: "Seychelles", + capital: "Victoria"), + Country(timezones: @["Africa/Khartoum"], + alpha2Code: "SD", + alpha3Code: "SDN", + continent: "Africa", + name: "Sudan", + capital: "Khartoum"), + Country(timezones: @["Europe/Stockholm"], + alpha2Code: "SE", + alpha3Code: "SWE", + continent: "Europe", + name: "Sweden", + capital: "Stockholm"), + Country(timezones: @["Asia/Singapore"], + alpha2Code: "SG", + alpha3Code: "SGP", + continent: "Asia", + name: "Singapore", + capital: "Singapore"), + Country(timezones: @["Europe/Ljubljana"], + alpha2Code: "SI", + alpha3Code: "SVN", + continent: "Europe", + name: "Slovenia", + capital: "Ljubljana"), + Country(timezones: @["Europe/Bratislava"], + alpha2Code: "SK", + alpha3Code: "SVK", + continent: "Europe", + name: "Slovakia", + capital: "Bratislava"), + Country(timezones: @["Africa/Freetown"], + alpha2Code: "SL", + alpha3Code: "SLE", + continent: "Africa", + name: "Sierra Leone", + capital: "Freetown"), + Country(timezones: @["Europe/San_Marino"], + alpha2Code: "SM", + alpha3Code: "SMR", + continent: "Europe", + name: "San Marino", + capital: "San Marino"), + Country(timezones: @["Africa/Dakar"], + alpha2Code: "SN", + alpha3Code: "SEN", + continent: "Africa", + name: "Senegal", + capital: "Dakar"), + Country(timezones: @["Africa/Mogadishu"], + alpha2Code: "SO", + alpha3Code: "SOM", + continent: "Africa", + name: "Somalia", + capital: "Mogadishu"), + Country(timezones: @["America/Paramaribo"], + alpha2Code: "SR", + alpha3Code: "SUR", + continent: "South America", + name: "Suriname", + capital: "Paramaribo"), + Country(timezones: @["Africa/Sao_Tome"], + alpha2Code: "ST", + alpha3Code: "STP", + continent: "Africa", + name: "S\xc3\xa3o Tom\xc3\xa9 and Pr\xc3\xadncipe", + capital: "S\xc3\xa3o Tom\xc3\xa9"), + Country(timezones: @["Asia/Damascus"], + alpha2Code: "SY", + alpha3Code: "SYR", + continent: "Asia", + name: "Syria", + capital: "Damascus"), + Country(timezones: @["Africa/Lome"], + alpha2Code: "TG", + alpha3Code: "TGO", + continent: "Africa", + name: "Togo", + capital: "Lom\xc3\xa9"), + Country(timezones: @["Asia/Bangkok"], + alpha2Code: "TH", + alpha3Code: "THA", + continent: "Asia", + name: "Thailand", + capital: "Bangkok"), + Country(timezones: @["Asia/Dushanbe"], + alpha2Code: "TJ", + alpha3Code: "TJK", + continent: "Asia", + name: "Tajikistan", + capital: "Dushanbe"), + Country(timezones: @["Asia/Ashgabat"], + alpha2Code: "TM", + alpha3Code: "TKM", + continent: "Asia", + name: "Turkmenistan", + capital: "Ashgabat"), + Country(timezones: @["Africa/Tunis"], + alpha2Code: "TN", + alpha3Code: "TUN", + continent: "Africa", + name: "Tunisia", + capital: "Tunis"), + Country(timezones: @["Pacific/Tongatapu"], + alpha2Code: "TO", + alpha3Code: "TON", + continent: "Oceania", + name: "Tonga", + capital: "Nuku\xca\xbbalofa"), + Country(timezones: @["Europe/Istanbul"], + alpha2Code: "TR", + alpha3Code: "TUR", + continent: "Asia", + name: "Turkey", + capital: "Ankara"), + Country(timezones: @["America/Port_of_Spain"], + alpha2Code: "TT", + alpha3Code: "TTO", + continent: "North America", + name: "Trinidad and Tobago", + capital: "Port of Spain"), + Country(timezones: @["Pacific/Funafuti"], + alpha2Code: "TV", + alpha3Code: "TUV", + continent: "Oceania", + name: "Tuvalu", + capital: "Funafuti"), + Country(timezones: @["Africa/Dar_es_Salaam"], + alpha2Code: "TZ", + alpha3Code: "TZA", + continent: "Africa", + name: "Tanzania", + capital: "Dodoma"), + Country(timezones: @["Europe/Kiev", + "Europe/Uzhgorod", + "Europe/Zaporozhye", + "Europe/Simferopol"], + alpha2Code: "UA", + alpha3Code: "UKR", + continent: "Europe", + name: "Ukraine", + capital: "Kiev"), + Country(timezones: @["Africa/Kampala"], + alpha2Code: "UG", + alpha3Code: "UGA", + continent: "Africa", + name: "Uganda", + capital: "Kampala"), + Country(timezones: @["America/New_York", + "America/Detroit", + "America/Kentucky/Louisville", + "America/Kentucky/Monticello", + "America/Indiana/Indianapolis", + "America/Indiana/Marengo", + "America/Indiana/Knox", + "America/Indiana/Vevay", + "America/Chicago", + "America/Indiana/Vincennes", + "America/Indiana/Petersburg", + "America/Menominee", + "America/North_Dakota/Center", + "America/North_Dakota/New_Salem", + "America/Denver", + "America/Boise", + "America/Shiprock", + "America/Phoenix", + "America/Los_Angeles", + "America/Anchorage", + "America/Juneau", + "America/Yakutat", + "America/Nome", + "America/Adak", + "Pacific/Honolulu"], + alpha2Code: "US", + alpha3Code: "USA", + continent: "North America", + name: "United States", + capital: "Washington, D.C."), + Country(timezones: @["America/Montevideo"], + alpha2Code: "UY", + alpha3Code: "URY", + continent: "South America", + name: "Uruguay", + capital: "Montevideo"), + Country(timezones: @["Asia/Samarkand", + "Asia/Tashkent"], + alpha2Code: "UZ", + alpha3Code: "UZB", + continent: "Asia", + name: "Uzbekistan", + capital: "Tashkent"), + Country(timezones: @["Europe/Vatican"], + alpha2Code: "VA", + alpha3Code: "VAT", + continent: "Europe", + name: "Vatican City", + capital: "Vatican City"), + Country(timezones: @["America/Caracas"], + alpha2Code: "VE", + alpha3Code: "VEN", + continent: "South America", + name: "Venezuela", + capital: "Caracas"), + Country(timezones: @["Asia/Saigon"], + alpha2Code: "VN", + alpha3Code: "VNM", + continent: "Asia", + name: "Vietnam", + capital: "Hanoi"), + Country(timezones: @["Pacific/Efate"], + alpha2Code: "VU", + alpha3Code: "VUT", + continent: "Oceania", + name: "Vanuatu", + capital: "Port Vila"), + Country(timezones: @["Asia/Aden"], + alpha2Code: "YE", + alpha3Code: "YEM", + continent: "Asia", + name: "Yemen", + capital: "Sana'a"), + Country(timezones: @["Africa/Lusaka"], + alpha2Code: "ZM", + alpha3Code: "ZMB", + continent: "Africa", + name: "Zambia", + capital: "Lusaka"), + Country(timezones: @["Africa/Harare"], + alpha2Code: "ZW", + alpha3Code: "ZWE", + continent: "Africa", + name: "Zimbabwe", + capital: "Harare"), + Country(timezones: @["Africa/Algiers"], + alpha2Code: "DZ", + alpha3Code: "DZA", + continent: "Africa", + name: "Algeria", + capital: "Algiers"), + Country(timezones: @["Europe/Sarajevo"], + alpha2Code: "BA", + alpha3Code: "BIH", + continent: "Europe", + name: "Bosnia and Herzegovina", + capital: "Sarajevo"), + Country(timezones: @["Asia/Phnom_Penh"], + alpha2Code: "KH", + alpha3Code: "KHM", + continent: "Asia", + name: "Cambodia", + capital: "Phnom Penh"), + Country(timezones: @["Africa/Bangui"], + alpha2Code: "CF", + alpha3Code: "CAF", + continent: "Africa", + name: "Central African Republic", + capital: "Bangui"), + Country(timezones: @["Africa/Ndjamena"], + alpha2Code: "TD", + alpha3Code: "TCD", + continent: "Africa", + name: "Chad", + capital: "N'Djamena"), + Country(timezones: @["Indian/Comoro"], + alpha2Code: "KM", + alpha3Code: "COM", + continent: "Africa", + name: "Comoros", + capital: "Moroni"), + Country(timezones: @["Europe/Zagreb"], + alpha2Code: "HR", + alpha3Code: "HRV", + continent: "Europe", + name: "Croatia", + capital: "Zagreb"), + Country(timezones: @["Asia/Dili"], + alpha2Code: "TL", + alpha3Code: "TLS", + continent: "Asia", + name: "East Timor", + capital: "Dili"), + Country(timezones: @["America/El_Salvador"], + alpha2Code: "SV", + alpha3Code: "SLV", + continent: "North America", + name: "El Salvador", + capital: "San Salvador"), + Country(timezones: @["Africa/Malabo"], + alpha2Code: "GQ", + alpha3Code: "GNQ", + continent: "Africa", + name: "Equatorial Guinea", + capital: "Malabo"), + Country(timezones: @["America/Grenada"], + alpha2Code: "GD", + alpha3Code: "GRD", + continent: "North America", + name: "Grenada", + capital: "St. George's"), + Country(timezones: @["Asia/Almaty", + "Asia/Qyzylorda", + "Asia/Aqtobe", + "Asia/Aqtau", + "Asia/Oral"], + alpha2Code: "KZ", + alpha3Code: "KAZ", + continent: "Asia", + name: "Kazakhstan", + capital: "Astana"), + Country(timezones: @["Asia/Vientiane"], + alpha2Code: "LA", + alpha3Code: "LAO", + continent: "Asia", + name: "Laos", + capital: "Vientiane"), + Country(timezones: @["Pacific/Truk", + "Pacific/Ponape", + "Pacific/Kosrae"], + alpha2Code: "FM", + alpha3Code: "FSM", + continent: "Oceania", + name: "Federated States of Micronesia", + capital: "Palikir"), + Country(timezones: @["Europe/Chisinau"], + alpha2Code: "MD", + alpha3Code: "MDA", + continent: "Europe", + name: "Moldova", + capital: "Chi\xc5\x9fin\xc4\x83u"), + Country(timezones: @["Europe/Monaco"], + alpha2Code: "MC", + alpha3Code: "MCO", + continent: "Europe", + name: "Monaco", + capital: "Monaco"), + Country(timezones: @["Europe/Podgorica"], + alpha2Code: "ME", + alpha3Code: "MNE", + continent: "Europe", + name: "Montenegro", + capital: "Podgorica"), + Country(timezones: @["Africa/Casablanca"], + alpha2Code: "MA", + alpha3Code: "MAR", + continent: "Africa", + name: "Morocco", + capital: "Rabat"), + Country(timezones: @["America/St_Kitts"], + alpha2Code: "KN", + alpha3Code: "KNA", + continent: "North America", + name: "Saint Kitts and Nevis", + capital: "Basseterre"), + Country(timezones: @["America/St_Lucia"], + alpha2Code: "LC", + alpha3Code: "LCA", + continent: "North America", + name: "Saint Lucia", + capital: "Castries"), + Country(timezones: @["America/St_Vincent"], + alpha2Code: "VC", + alpha3Code: "VCT", + continent: "North America", + name: "Saint Vincent and the Grenadines", + capital: "Kingstown"), + Country(timezones: @["Pacific/Apia"], + alpha2Code: "WS", + alpha3Code: "WSM", + continent: "Oceania", + name: "Samoa", + capital: "Apia"), + Country(timezones: @["Europe/Belgrade"], + alpha2Code: "RS", + alpha3Code: "SRB", + continent: "Europe", + name: "Serbia", + capital: "Belgrade"), + Country(timezones: @["Africa/Johannesburg"], + alpha2Code: "ZA", + alpha3Code: "ZAF", + continent: "Africa", + name: "South Africa", + capital: "Pretoria"), + Country(timezones: @["Europe/Madrid", + "Africa/Ceuta", + "Atlantic/Canary"], + alpha2Code: "ES", + alpha3Code: "ESP", + continent: "Europe", + name: "Spain", + capital: "Madrid"), + Country(timezones: @["Asia/Colombo"], + alpha2Code: "LK", + alpha3Code: "LKA", + continent: "Asia", + name: "Sri Lanka", + capital: "Sri Jayewardenepura Kotte"), + Country(timezones: @["Africa/Mbabane"], + alpha2Code: "SZ", + alpha3Code: "SWZ", + continent: "Africa", + name: "Swaziland", + capital: "Mbabane"), + Country(timezones: @["Europe/Zurich"], + alpha2Code: "CH", + alpha3Code: "CHE", + continent: "Europe", + name: "Switzerland", + capital: "Bern"), + Country(timezones: @["Asia/Dubai"], + alpha2Code: "AE", + alpha3Code: "ARE", + continent: "Asia", + name: "United Arab Emirates", + capital: "Abu Dhabi"), + Country(timezones: @["Europe/London"], + alpha2Code: "GB", + alpha3Code: "GBR", + continent: "Europe", + name: "United Kingdom", + capital: "London"), + ] + +let + countryNames = countries.mapIt(it.name) + const cityPrefixes = @["North", "East", "West", "South", "New", "Lake", "Port"] citySuffixes = @[ @@ -317,26 +1624,26 @@ const "$lastName$citySuffix", ] - street_name_formats = @[ - "{{first_name}} {{street_suffix}}", - "{{last_name}} {{street_suffix}}", + streetNameFormats = @[ + "$firstName $streetSuffix", + "$lastName $streetSuffix", ] - street_address_formats = @[ - "{{building_number}} {{street_name}}", - "{{building_number}} {{street_name}} {{secondary_address}}", + streetAddressFormats = @[ + "$buildingNumber $streetName", + "$buildingNumber $streetName $secondaryAddress", ] addressFormats = @[ - "$streetAddress\n$city, $stateAbbr $postcode", + "$streetAddress $city, $stateAbbr $postcode", ] # address_formats = OrderedDict(( - # ("{{street_address}}\n{{city}}, {{state_abbr}} {{postcode}}", 25), + # ("{{street_address}} {{city}}, {{state_abbr}} {{postcode}}", 25), # # military address formatting. - # ("{{military_apo}}\nAPO {{military_state}} {{postcode}}", 1), - # ("{{military_ship}} {{last_name}}\nFPO {{military_state}} {{postcode}}", 1), - # ("{{military_dpo}}\nDPO {{military_state}} {{postcode}}", 1), + # ("{{military_apo}} APO {{military_state}} {{postcode}}", 1), + # ("{{military_ship}} {{last_name}} FPO {{military_state}} {{postcode}}", 1), + # ("{{military_dpo}} DPO {{military_state}} {{postcode}}", 1), # )) secondaryAddressFormats = @["Apt. $number", "Suite $number"] @@ -369,6 +1676,7 @@ proc buildingNumber*(f: Faker): string = ## Output: ## 8345 + # TODO: formatNumbers $f.rand.rand(1..65535) proc city*(f: Faker): string = @@ -376,8 +1684,8 @@ proc city*(f: Faker): string = cityFmt = f.rand.sample(cityFormats) cityPrefix = f.cityPrefix() citySuffix = f.citySuffix() - firstName = "John" - lastName = "Marker" + firstName = f.firstName() + lastName = f.lastName() cityFmt % @[ "cityPrefix", cityPrefix, "citySuffix", citySuffix, @@ -405,7 +1713,8 @@ proc citySuffix*(f: Faker): string = f.rand.sample(citySuffixes) -proc country*(f: Faker): string = "TODO" +proc country*(f: Faker): string = + f.rand.sample(countryNames) proc countryCode*(f: Faker, representation: string): string = "TODO" proc militaryApo*(f: Faker): string = ## Returns random military apo. @@ -473,9 +1782,33 @@ proc stateAbbr*(f: Faker, includeTerritories: bool): string = else: f.rand.sample(statesAbbr) -proc streetAddress*(f: Faker): string = "TODO" -proc streetName*(f: Faker): string = "TODO" -proc streetSuffix*(f: Faker): string = "TODO" +proc streetAddress*(f: Faker): string = + let + fmt = f.rand.sample(streetAddressFormats) + buildingNumber = f.buildingNumber() + streetName = f.streetName() + secondaryAddress = f.secondaryAddress() + fmt % @[ + "buildingNumber", buildingNumber, + "streetName", streetName, + "secondaryAddress", secondaryAddress, + ] + +proc streetName*(f: Faker): string = + let + fmt = f.rand.sample(streetNameFormats) + firstName = f.firstName() + lastName = f.lastName() + streetSuffix = f.streetSuffix() + fmt % @[ + "firstName", firstName, + "lastName", lastName, + "streetSuffix", streetSuffix, + ] + +proc streetSuffix*(f: Faker): string = + f.rand.sample(streetSuffixes) + proc zipcode*(f: Faker): string = ## Returns random zipcode. ## From 8fd719a9283371babb9e2e2b0bca8c3aa8b90162 Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 14:37:46 +0900 Subject: [PATCH 2/2] :bug: Change number formats of person module --- src/faker/provider/address/address_en_US.nim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/faker/provider/address/address_en_US.nim b/src/faker/provider/address/address_en_US.nim index 4d18005..610a06d 100644 --- a/src/faker/provider/address/address_en_US.nim +++ b/src/faker/provider/address/address_en_US.nim @@ -3,6 +3,7 @@ from strformat import `&` from sequtils import mapIt from ../person import lastName, firstName +from ../util import formatNumbers include interfaces @@ -1676,8 +1677,9 @@ proc buildingNumber*(f: Faker): string = ## Output: ## 8345 - # TODO: formatNumbers - $f.rand.rand(1..65535) + let fmt = f.rand.sample(buildingNumberFormats) + var r = f.rand + r.formatNumbers(fmt) proc city*(f: Faker): string = let @@ -1753,8 +1755,9 @@ proc postcode*(f: Faker): string = ## Output: ## 47542 - let pc = $f.rand.rand(501..99950) - &"{pc:>05}" + let fmt = f.rand.sample(postcodeFormats) + var r = f.rand + r.formatNumbers(fmt) proc secondaryAddress*(f: Faker): string = ## Returns random secondary address.