Skip to content

Commit

Permalink
Parser of the resolver files
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Jan 9, 2025
1 parent 38e1ccc commit 3d6c2e9
Show file tree
Hide file tree
Showing 3 changed files with 594 additions and 0 deletions.
273 changes: 273 additions & 0 deletions resolver/country.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@

country_code_table = [
[1, "AD"],
[2, "AE"],
[3, "AF"],
[4, "AG"],
[5, "AI"],
[6, "AL"],
[7, "AM"],
[8, "AO"],
[9, "AQ"],
[10, "AR"],
[11, "AS"],
[12, "AT"],
[13, "AU"],
[14, "AW"],
[15, "AX"],
[16, "AZ"],
[17, "BA"],
[18, "BB"],
[19, "BD"],
[20, "BE"],
[21, "BF"],
[22, "BG"],
[23, "BH"],
[24, "BI"],
[25, "BJ"],
[26, "BL"],
[27, "BM"],
[28, "BN"],
[29, "BO"],
[30, "BQ"],
[31, "BR"],
[32, "BS"],
[33, "BT"],
[34, "BV"],
[35, "BW"],
[36, "BY"],
[37, "BZ"],
[38, "CA"],
[39, "CC"],
[40, "CD"],
[41, "CF"],
[42, "CG"],
[43, "CH"],
[44, "CI"],
[45, "CK"],
[46, "CL"],
[47, "CM"],
[48, "CN"],
[49, "CO"],
[50, "CR"],
[51, "CU"],
[52, "CV"],
[53, "CW"],
[54, "CX"],
[55, "CY"],
[56, "CZ"],
[57, "DE"],
[58, "DJ"],
[59, "DK"],
[60, "DM"],
[61, "DO"],
[62, "DZ"],
[63, "EC"],
[64, "EE"],
[65, "EG"],
[66, "EH"],
[67, "ER"],
[68, "ES"],
[69, "ET"],
[70, "FI"],
[71, "FJ"],
[72, "FK"],
[73, "FM"],
[74, "FO"],
[75, "FR"],
[76, "GA"],
[77, "GD"],
[78, "GE"],
[79, "GF"],
[80, "GG"],
[81, "GH"],
[82, "GI"],
[83, "GL"],
[84, "GM"],
[85, "GN"],
[86, "GP"],
[87, "GQ"],
[88, "GR"],
[89, "GS"],
[90, "GT"],
[91, "GU"],
[92, "GW"],
[93, "GY"],
[94, "HK"],
[95, "HM"],
[96, "HN"],
[97, "HR"],
[98, "HT"],
[99, "HU"],
[100, "ID"],
[101, "IE"],
[102, "IL"],
[103, "IM"],
[104, "IN"],
[105, "IO"],
[106, "IQ"],
[107, "IR"],
[108, "IS"],
[109, "IT"],
[110, "JE"],
[111, "JM"],
[112, "JO"],
[113, "JP"],
[114, "KE"],
[115, "KG"],
[116, "KH"],
[117, "KI"],
[118, "KM"],
[119, "KN"],
[120, "KP"],
[121, "KR"],
[122, "KW"],
[123, "KY"],
[124, "KZ"],
[125, "LA"],
[126, "LB"],
[127, "LC"],
[128, "LI"],
[129, "LK"],
[130, "LR"],
[131, "LS"],
[132, "LT"],
[133, "LU"],
[134, "LV"],
[135, "LY"],
[136, "MA"],
[137, "MC"],
[138, "MD"],
[139, "ME"],
[140, "MF"],
[141, "MG"],
[142, "MH"],
[143, "MK"],
[144, "ML"],
[145, "MM"],
[146, "MN"],
[147, "MO"],
[148, "MP"],
[149, "MQ"],
[150, "MR"],
[151, "MS"],
[152, "MT"],
[153, "MU"],
[154, "MV"],
[155, "MW"],
[156, "MX"],
[157, "MY"],
[158, "MZ"],
[159, "NA"],
[160, "NC"],
[161, "NE"],
[162, "NF"],
[163, "NG"],
[164, "NI"],
[165, "NL"],
[166, "NO"],
[167, "NP"],
[168, "NR"],
[169, "NU"],
[170, "NZ"],
[171, "OM"],
[172, "PA"],
[173, "PE"],
[174, "PF"],
[175, "PG"],
[176, "PH"],
[177, "PK"],
[178, "PL"],
[179, "PM"],
[180, "PN"],
[181, "PR"],
[182, "PS"],
[183, "PT"],
[184, "PW"],
[185, "PY"],
[186, "QA"],
[187, "RE"],
[188, "RO"],
[189, "RS"],
[190, "RU"],
[191, "RW"],
[192, "SA"],
[193, "SB"],
[194, "SC"],
[195, "SD"],
[196, "SE"],
[197, "SG"],
[198, "SH"],
[199, "SI"],
[200, "SJ"],
[201, "SK"],
[202, "SL"],
[203, "SM"],
[204, "SN"],
[205, "SO"],
[206, "SR"],
[207, "SS"],
[208, "ST"],
[209, "SV"],
[210, "SX"],
[211, "SY"],
[212, "SZ"],
[213, "TC"],
[214, "TD"],
[215, "TF"],
[216, "TG"],
[217, "TH"],
[218, "TJ"],
[219, "TK"],
[220, "TL"],
[221, "TM"],
[222, "TN"],
[223, "TO"],
[224, "TR"],
[225, "TT"],
[226, "TV"],
[227, "TW"],
[228, "TZ"],
[229, "UA"],
[230, "UG"],
[231, "GB"],
[232, "UM"],
[233, "US"],
[234, "UY"],
[235, "UZ"],
[236, "VA"],
[237, "VC"],
[238, "VE"],
[239, "VG"],
[240, "VI"],
[241, "VN"],
[242, "VU"],
[243, "WF"],
[244, "WS"],
[245, "YE"],
[246, "YT"],
[247, "ZA"],
[248, "ZM"],
[249, "ZW"],
]

def country_code_from_number(number):
alpha_code = "ZZ"
if number > 0 and number <= 249:
table_line = country_code_table[number - 1]
alpha_code= table_line[1]
return alpha_code

def country_code_from_c999(c999):
alpha_code = c999
if c999.startswith("c"):
try:
number = int(c999[1:])
if number > 0 and number <= 249:
table_line = country_code_table[number - 1]
alpha_code = table_line[1]
except:
pass
return alpha_code


Loading

0 comments on commit 3d6c2e9

Please sign in to comment.