Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fst-20220211, quarterly update #1

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
75 changes: 75 additions & 0 deletions python/dialpad_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import phonenumbers

# Fixed by Phonenumbers Cases
valid_strings = ['+442083661177',
'+658003211137',
'+20573925008',
'+2057392500',
'+20225777444',
'+84384813220',
'+84357659677',
'+56232512653', # https://switchcomm.atlassian.net/browse/TEL-9285
'+525547808256',
'+13677395285',
'+16892226575',
'+18404440531',
'+48477314848',
'+6569786318',
'+6560115374', # https://switchcomm.atlassian.net/browse/TEL-14616
'+576015088865', # https://switchcomm.atlassian.net/browse/TEL-14616
'+5715088865', # https://switchcomm.atlassian.net/browse/TEL-14616
]

print '######### - VALID BY LIBRARY - ################'
for l in valid_strings:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x

# To be fixed by Dialpad Changes
dialpad_cases = ['+6278033212174', # https://switchcomm.atlassian.net/browse/DP-13742
'+63283168971', # Philipines
'+8031000000141', # Dialpadistan
'+2250757715034', # Ivory Coast - New Format
'+2252721214601', # Ivory Coast - New Format
]

print '######### - VALID BY DIALPAD - ################'
for l in dialpad_cases:
try:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x
except Exception as e:
print '%15s' % l, '%25s' % e

# Invalid Strings
invalid_strings = ['+4916190899790', # https://switchcomm.atlassian.net/browse/TEL-8824 Not Fixed
'+2022577744',
'+205739250',
]

print '######### - INVALID NUMBERS - ################'
for l in invalid_strings:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x

# National Format match
national_format_match = {'+525547808256': '55 4780 8256'}

print '######### - NUMBER FORMAT VALIDITY - ################'
for l in national_format_match:
x = phonenumbers.parse(l, None)
y = phonenumbers.format_number(x, phonenumbers.PhoneNumberFormat.NATIONAL)
if national_format_match[l] == y:
status = 'Success'
else:
status = 'Failed'
print (l), '-> %10s : %s' % (y, status)

# Number validity check
number_validity_check = {'1932621160': 'BR'}
print '######### - REGION NUMBER VALIDITY - ###############'
for l in number_validity_check:
region = number_validity_check[l]
x = phonenumbers.parse(l, region)
print '%15s' % l, '%10s -> Region : %5s' % (phonenumbers.is_valid_number(x), region)

5 changes: 5 additions & 0 deletions python/phonenumbers/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

_AVAILABLE_REGION_CODES = ['AC','AD','AE','AF','AG','AI','AL','AM','AO','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BQ','BR','BS','BT','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP','GQ','GR','GT','GU','GW','GY','HK','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TA','TC','TD','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','XK','YE','YT','ZA','ZM','ZW']
_AVAILABLE_NONGEO_COUNTRY_CODES = [800, 808, 870, 878, 881, 882, 883, 888, 979]
_DIALPADISTAN_NONGEO_REGION_CODES = ['DP']

def _load_region(code):
__import__("region_%s" % code, globals(), locals(),
Expand All @@ -29,6 +30,9 @@ def _load_region(code):
for _country_code in _AVAILABLE_NONGEO_COUNTRY_CODES:
PhoneMetadata.register_nongeo_region_loader(_country_code, _load_region)

for region_code in _DIALPADISTAN_NONGEO_REGION_CODES:
PhoneMetadata.register_region_loader(region_code, _load_region)

from .alt_format_255 import PHONE_ALT_FORMAT_255
from .alt_format_27 import PHONE_ALT_FORMAT_27
from .alt_format_30 import PHONE_ALT_FORMAT_30
Expand Down Expand Up @@ -298,4 +302,5 @@ def _load_region(code):
995: ("GE",),
996: ("KG",),
998: ("UZ",),
803: ("DP",), # Dialpadistan
}
8 changes: 8 additions & 0 deletions python/phonenumbers/data/region_DP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Auto-generated file, do not edit by hand. 800 metadata"""
from ..phonemetadata import NumberFormat, PhoneNumberDesc, PhoneMetadata

PHONE_METADATA_DP = PhoneMetadata(id='DP', country_code=803, international_prefix=None,
general_desc=PhoneNumberDesc(national_number_pattern='\\d{10}', example_number='1000000141', possible_length=(10,)),
voip=PhoneNumberDesc(national_number_pattern='\\d{10}', example_number='1000000141', possible_length=(10,)),
number_format=[NumberFormat(pattern='(\\d{3})(\\d{7})', format='\\1\\2')],
leading_zero_possible=False)
2 changes: 1 addition & 1 deletion python/phonenumbers/data/region_ID.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
general_desc=PhoneNumberDesc(national_number_pattern='(?:(?:00[1-9]|8\\d)\\d{4}|[1-36])\\d{6}|00\\d{10}|[1-9]\\d{8,10}|[2-9]\\d{7}', possible_length=(7, 8, 9, 10, 11, 12, 13), possible_length_local_only=(5, 6)),
fixed_line=PhoneNumberDesc(national_number_pattern='2[124]\\d{7,8}|619\\d{8}|2(?:1(?:14|500)|2\\d{3})\\d{3}|61\\d{5,8}|(?:2(?:[35][1-4]|6[0-8]|7[1-6]|8\\d|9[1-8])|3(?:1|[25][1-8]|3[1-68]|4[1-3]|6[1-3568]|7[0-469]|8\\d)|4(?:0[1-589]|1[01347-9]|2[0-36-8]|3[0-24-68]|43|5[1-378]|6[1-5]|7[134]|8[1245])|5(?:1[1-35-9]|2[25-8]|3[124-9]|4[1-3589]|5[1-46]|6[1-8])|6(?:[25]\\d|3[1-69]|4[1-6])|7(?:02|[125][1-9]|[36]\\d|4[1-8]|7[0-36-9])|9(?:0[12]|1[013-8]|2[0-479]|5[125-8]|6[23679]|7[159]|8[01346]))\\d{5,8}', example_number='218350123', possible_length=(7, 8, 9, 10, 11), possible_length_local_only=(5, 6)),
mobile=PhoneNumberDesc(national_number_pattern='8[1-35-9]\\d{7,10}', example_number='812345678', possible_length=(9, 10, 11, 12)),
toll_free=PhoneNumberDesc(national_number_pattern='00[17]803\\d{7}|(?:177\\d|800)\\d{5,7}|001803\\d{6}', example_number='8001234567', possible_length=(8, 9, 10, 11, 12, 13)),
toll_free=PhoneNumberDesc(national_number_pattern='00[17]803\\d{7}|(?:177\\d|800)\\d{5,7}|001803\\d{6}|7803\\d{7}', example_number='8001234567', possible_length=(8, 9, 10, 11, 12, 13)),
premium_rate=PhoneNumberDesc(national_number_pattern='809\\d{7}', example_number='8091234567', possible_length=(10,)),
shared_cost=PhoneNumberDesc(national_number_pattern='804\\d{7}', example_number='8041234567', possible_length=(10,)),
uan=PhoneNumberDesc(national_number_pattern='(?:1500|8071\\d{3})\\d{3}', example_number='8071123456', possible_length=(7, 10)),
Expand Down