Skip to content

Commit 188fc46

Browse files
committed
Merge branch 'dev' into python3
Conflicts: python/buildmetadatafromxml.py python/makefile python/phonenumbers/data/region_AR.py python/phonenumbers/data/region_BA.py python/phonenumbers/data/region_EC.py python/phonenumbers/data/region_PF.py python/phonenumbers/data/region_UZ.py python/phonenumbers/geocoder.py python/phonenumbers/geodata/__init__.py python/phonenumbers/phonenumberutil.py python/tests/phonenumberutiltest.py
2 parents 094c727 + 58b339b commit 188fc46

39 files changed

Lines changed: 1806 additions & 549 deletions

python/HISTORY

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
=====================
3+
What's new in 5.0b1
4+
=====================
5+
6+
Merge up to upstream Subversion revision 492.
7+
8+
9+
210
=====================
311
What's new in 4.9b1
412
=====================

python/buildmetadatafromxml.py

Lines changed: 113 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import sys
4242
import os
4343
import re
44+
import getopt
4445
import datetime
4546
from xml.etree import ElementTree as etree
4647

@@ -56,6 +57,8 @@
5657
TOP_XPATH = "territories"
5758
# XML element name for the territory element
5859
TERRITORY_TAG = "territory"
60+
# Marker for unavailable entries
61+
DATA_NA = "NA"
5962

6063
# Boilerplate text for generated Python files
6164
METADATA_FILE_PROLOG = '"""Auto-generated file, do not edit by hand."""'
@@ -71,6 +74,11 @@
7174
from %(module)s.phonemetadata import NumberFormat, PhoneNumberDesc, PhoneMetadata
7275
'''
7376

77+
# Boilerplate header for individual country-code alternate number format data files
78+
_ALT_FORMAT_METADATA_PROLOG = '''"""Auto-generated file, do not edit by hand. %s metadata"""
79+
from %s.phonemetadata import NumberFormat
80+
'''
81+
7482
# Copyright notice covering the XML metadata; include current year.
7583
COPYRIGHT_NOTICE = """# Copyright (C) 2010-%s The Libphonenumber Authors
7684
#
@@ -145,6 +153,30 @@ def _expand_formatting_rule(rule, national_prefix):
145153
return rule
146154

147155

156+
class XAlternateNumberFormat(UnicodeMixin):
157+
"""Parse alternate NumberFormat objects from XML element"""
158+
def __init__(self, xtag):
159+
if xtag is None:
160+
self.o = None
161+
else:
162+
self.o = NumberFormat()
163+
self.o._mutable = True
164+
self.o.pattern = xtag.attrib['pattern'] # REQUIRED attribute
165+
self.o.format = _get_unique_child_value(xtag, 'format')
166+
if self.o.format is None:
167+
raise Exception("No format pattern found")
168+
else:
169+
# Replace '$1' etc with '\1' to match Python regexp group reference format
170+
self.o.format = re.sub('\$', ur'\\', self.o.format)
171+
xleading_digits = xtag.findall("leadingDigits")
172+
for xleading_digit in xleading_digits:
173+
self.o.leading_digits_pattern.append(_dews_re(xleading_digit.text))
174+
# Currently this assumes no intlFormat elements in the element
175+
176+
def __unicode__(self):
177+
return unicode(self.o)
178+
179+
148180
class XNumberFormat(UnicodeMixin):
149181
"""Parsed NumberFormat objects from XML element"""
150182
def __init__(self, owning_xterr, xtag, national_prefix,
@@ -217,7 +249,7 @@ def __init__(self, owning_xterr, xtag, national_prefix,
217249
else:
218250
# Replace '$1' etc with '\1' to match Python regexp group reference format
219251
intl_format = re.sub('\$', u(r'\\'), intl_format)
220-
if intl_format != "NA":
252+
if intl_format != DATA_NA:
221253
self.io.format = intl_format
222254
owning_xterr.has_explicit_intl_format = True
223255
if self.io.format is not None:
@@ -239,8 +271,8 @@ def __init__(self, xtag,
239271
self.o.example_number = None
240272
if xtag is None:
241273
if fill_na:
242-
self.o.national_number_pattern = "NA"
243-
self.o.possible_number_pattern = "NA"
274+
self.o.national_number_pattern = DATA_NA
275+
self.o.possible_number_pattern = DATA_NA
244276
return
245277
# Start with the template values
246278
if template is not None:
@@ -263,6 +295,26 @@ def __unicode__(self):
263295
return u(self.o)
264296

265297

298+
class XAlternateTerritory(UnicodeMixin):
299+
"""Parse alternate format metadata from XML element (territory)"""
300+
def __init__(self, xterritory):
301+
self.country_code = int(xterritory.attrib['countryCode'])
302+
# Look for available formats
303+
self.number_format = []
304+
formats = _get_unique_child(xterritory, "availableFormats")
305+
if formats is not None:
306+
for xelt in formats.findall("numberFormat"):
307+
# Create an XNumberFormat object, which contains a NumberFormat object
308+
# or two, and which self-registers them with self.o
309+
self.number_format.append(XAlternateNumberFormat(xelt).o)
310+
if len(self.number_format) == 0:
311+
raise Exception("No number formats found in available formats")
312+
# Currently this assumes no intlFormat elements in the file
313+
314+
def __unicode__(self):
315+
return unicode(self.number_format)
316+
317+
266318
class XTerritory(UnicodeMixin):
267319
"""Parse PhoneMetadata from XML element (territory)"""
268320
def __init__(self, xterritory):
@@ -389,6 +441,23 @@ def __init__(self, filename):
389441
self.territory[id] = terrobj
390442
else:
391443
raise Exception("Unexpected element %s found" % xterritory.tag)
444+
self.alt_territory = None
445+
446+
def add_alternate_formats(self, filename):
447+
"""Add phone number alternate format metadata retrieved from XML"""
448+
with open(filename, "r") as infile:
449+
xtree = etree.parse(infile)
450+
self.alt_territory = {} # country_code to XAlternateTerritory
451+
xterritories = xtree.find(TOP_XPATH)
452+
for xterritory in xterritories:
453+
if xterritory.tag == TERRITORY_TAG:
454+
terrobj = XAlternateTerritory(xterritory)
455+
id = str(terrobj.country_code)
456+
if id in self.alt_territory:
457+
raise Exception("Duplicate entry for %s" % id)
458+
self.alt_territory[id] = terrobj
459+
else:
460+
raise Exception("Unexpected element %s found" % xterritory.tag)
392461

393462
def __unicode__(self):
394463
return u("\n").join([u("%s: %s") % (country_id, territory) for country_id, territory in self.territory.items()])
@@ -400,6 +469,13 @@ def emit_metadata_for_region_py(self, region, region_filename, module_prefix):
400469
prnt(_REGION_METADATA_PROLOG % {'region': terrobj.identifier(), 'module': module_prefix}, file=outfile)
401470
prnt("PHONE_METADATA_%s = %s" % (terrobj.identifier(), terrobj), file=outfile)
402471

472+
def emit_alt_formats_for_cc_py(self, cc, cc_filename, module_prefix):
473+
"""Emit Python code generating the alternate format metadata for the given country code"""
474+
terrobj = self.alt_territory[cc]
475+
with open(cc_filename, "w") as outfile:
476+
print >> outfile, _ALT_FORMAT_METADATA_PROLOG % (cc, module_prefix)
477+
print >> outfile, "PHONE_ALT_FORMAT_%s = %s" % (cc, terrobj)
478+
403479
def emit_metadata_py(self, datadir, module_prefix):
404480
"""Emit Python code for the phone number metadata to the given file, and
405481
to a data/ subdirectory in the same directory as that file."""
@@ -413,12 +489,24 @@ def emit_metadata_py(self, datadir, module_prefix):
413489
filename = os.path.join(datadir, "region_%s.py" % country_id)
414490
self.emit_metadata_for_region_py(country_id, filename, module_prefix)
415491

492+
# Same for any per-country-code alternate format files
493+
if self.alt_territory is not None:
494+
for country_code in sorted(self.alt_territory.keys()):
495+
filename = os.path.join(datadir, "alt_format_%s.py" % country_code)
496+
self.emit_alt_formats_for_cc_py(country_code, filename, module_prefix)
497+
416498
# Now build a module file that includes them all
417499
with open(modulefilename, "w") as outfile:
418500
prnt(METADATA_FILE_PROLOG, file=outfile)
419501
prnt(COPYRIGHT_NOTICE, file=outfile)
420502
for country_id in sorted(self.territory.keys()):
421503
prnt("from .region_%s import PHONE_METADATA_%s" % (country_id, country_id), file=outfile)
504+
if self.alt_territory is not None:
505+
for country_code in sorted(self.alt_territory.keys()):
506+
prnt("from .alt_format_%s import PHONE_ALT_FORMAT_%s" % (country_code, country_code), file=outfile)
507+
prnt("_ALT_NUMBER_FORMATS = {%s}" %
508+
", ".join(["%s: PHONE_ALT_FORMAT_%s" % (cc, cc) for cc in sorted(self.alt_territory.keys())]),
509+
file=outfile)
422510
# Emit the mapping from country code to region code
423511
prnt(_COUNTRY_CODE_TO_REGION_CODE_PROLOG, file=outfile)
424512
prnt("_COUNTRY_CODE_TO_REGION_CODE = {", file=outfile)
@@ -442,11 +530,30 @@ def emit_metadata_py(self, datadir, module_prefix):
442530

443531
def _standalone(argv):
444532
"""Parse the given XML file and emit generated code."""
445-
if len(argv) != 3:
533+
alternate = None
534+
try:
535+
opts, args = getopt.getopt(argv, "ha:", ("help", "alt="))
536+
except getopt.GetoptError:
537+
prnt(__doc__, file=sys.stderr)
538+
sys.exit(1)
539+
for opt, arg in opts:
540+
if opt in ("-h", "--help"):
541+
prnt(__doc__, file=sys.stderr)
542+
sys.exit(1)
543+
elif opt in ("-a", "--alt"):
544+
alternate = arg
545+
else:
546+
prnt("Unknown option %s" % opt, file=sys.stderr)
547+
prnt(__doc__, file=sys.stderr)
548+
sys.exit(1)
549+
550+
if len(args) != 3:
446551
prnt(__doc__, file=sys.stderr)
447552
sys.exit(1)
448-
pmd = XPhoneNumberMetadata(argv[0])
449-
pmd.emit_metadata_py(argv[1], argv[2])
553+
pmd = XPhoneNumberMetadata(args[0])
554+
if alternate is not None:
555+
pmd.add_alternate_formats(alternate)
556+
pmd.emit_metadata_py(args[1], args[2])
450557

451558

452559
if __name__ == "__main__":

python/makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ phonenumbers/geodata/locale.py: DumpLocale.class
1111

1212
locale: phonenumbers/geodata/locale.py
1313

14-
phonenumbers/geodata/__init__.py: buildgeocodingdata.py ../resources/geocoding
14+
phonenumbers/geodata:
15+
mkdir $@
16+
phonenumbers/geodata/__init__.py: buildgeocodingdata.py ../resources/geocoding | phonenumbers/geodata
1517
$(PYTHON) buildgeocodingdata.py ../resources/geocoding $@ .
1618

17-
tests/testgeodata/__init__.py: buildgeocodingdata.py ../resources/test/geocoding
18-
$(PYTHON) buildgeocodingdata.py ../resources/test/geocoding $@ phonenumbers
19+
tests/testgeodata:
20+
mkdir $@
21+
tests/testgeodata/__init__.py: buildgeocodingdata.py ../resources/test/geocoding | tests/testgeodata
22+
$(PYTHON) buildgeocodingdata.py ../resources/test/geocoding $@ .
1923

2024
geodata: phonenumbers/geodata/__init__.py tests/testgeodata/__init__.py
2125

22-
phonenumbers/data/__init__.py: ../resources/PhoneNumberMetaData.xml buildmetadatafromxml.py
23-
$(PYTHON) buildmetadatafromxml.py ../resources/PhoneNumberMetaData.xml phonenumbers/data .
26+
phonenumbers/data/__init__.py: ../resources/PhoneNumberMetaData.xml ../resources/PhoneNumberAlternateFormats.xml buildmetadatafromxml.py
27+
$(PYTHON) buildmetadatafromxml.py --alt ../resources/PhoneNumberAlternateFormats.xml ../resources/PhoneNumberMetaData.xml phonenumbers/data .
2428

2529
tests/testdata/__init__.py: ../resources/PhoneNumberMetaDataForTesting.xml buildmetadatafromxml.py
2630
$(PYTHON) buildmetadatafromxml.py ../resources/PhoneNumberMetaDataForTesting.xml tests/testdata phonenumbers
@@ -71,11 +75,11 @@ clean: coverage_clean profile_clean
7175
rm -rf tests/__pycache__ tests/testdata/__pycache__ tests/testgeodata/__pycache__
7276
rm -rf build deb_dist dist
7377

74-
metaclean: clean
78+
metaclean:
7579
rm -rf phonenumbers/data tests/testdata
76-
rm -rf phonenumbers/geodata/* tests/testgeodata/*
80+
rm -rf phonenumbers/geodata tests/testgeodata
7781

78-
distclean: metaclean
82+
distclean: clean metaclean
7983
rm -rf $(PACKAGE).egg-info
8084
rm -rf build
8185
rm -f DumpLocale.class

python/phonenumbers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
# Version number is taken from the upstream libphonenumber version
123123
# together with an indication of the version of the Python-specific code.
124-
__version__ = "4.9b1"
124+
__version__ = "5.0b1"
125125

126126
__all__ = ['PhoneNumber', 'CountryCodeSource', 'FrozenPhoneNumber',
127127
'REGION_CODE_FOR_NON_GEO_ENTITY', 'NumberFormat', 'PhoneNumberDesc', 'PhoneMetadata',

python/phonenumbers/data/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@
265265
from .region_ZA import PHONE_METADATA_ZA
266266
from .region_ZM import PHONE_METADATA_ZM
267267
from .region_ZW import PHONE_METADATA_ZW
268+
from .alt_format_44 import PHONE_ALT_FORMAT_44
269+
from .alt_format_49 import PHONE_ALT_FORMAT_49
270+
from .alt_format_55 import PHONE_ALT_FORMAT_55
271+
from .alt_format_61 import PHONE_ALT_FORMAT_61
272+
from .alt_format_81 import PHONE_ALT_FORMAT_81
273+
_ALT_NUMBER_FORMATS = {44: PHONE_ALT_FORMAT_44, 49: PHONE_ALT_FORMAT_49, 55: PHONE_ALT_FORMAT_55, 61: PHONE_ALT_FORMAT_61, 81: PHONE_ALT_FORMAT_81}
268274

269275
# A mapping from a country code to the region codes which
270276
# denote the country/region represented by that country code.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Auto-generated file, do not edit by hand. 44 metadata"""
2+
from ..phonemetadata import NumberFormat
3+
4+
PHONE_ALT_FORMAT_44 = [NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{4})', format='\\1-\\2-\\3', leading_digits_pattern=['20']), NumberFormat(pattern='(\\d{4})(\\d{3})(\\d{3})', format='\\1 \\2 \\3', leading_digits_pattern=['1[2-48][02-9]|7(?:[1-5789]|624)']), NumberFormat(pattern='(\\d{3})(\\d{4})(\\d{3})', format='\\1 \\2 \\3', leading_digits_pattern=['7[1-5789]']), NumberFormat(pattern='(80\\d)(\\d{3,4})(\\d{3})', format='\\1 \\2 \\3', leading_digits_pattern=['80'])]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Auto-generated file, do not edit by hand. 49 metadata"""
2+
from ..phonemetadata import NumberFormat
3+
4+
PHONE_ALT_FORMAT_49 = [NumberFormat(pattern='(\\d{2})(\\d{3})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['3[02]|40|[68]9']), NumberFormat(pattern='(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})', format='\\1/\\2 \\3 \\4 \\5', leading_digits_pattern=['3[02]|40|[68]9']), NumberFormat(pattern='(\\d{2})(\\d{4})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['3[02]|40|[68]9']), NumberFormat(pattern='(\\d{2})(\\d{3})(\\d{2})(\\d{2})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['3[02]|40|[68]9']), NumberFormat(pattern='(\\d{2})(\\d{3})(\\d{3})(\\d{2,3})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['3[02]|40|[68]9']), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{2,4})', format='\\1/\\2 \\3', leading_digits_pattern=['2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)']), NumberFormat(pattern='(\\d{3})(\\d{4})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)']), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{2})(\\d{2})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)']), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{2})(\\d{2})(\\d)', format='\\1/\\2 \\3 \\4 \\5', leading_digits_pattern=['2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)']), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{3})(\\d{2,3})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)']), NumberFormat(pattern='(\\d{4})(\\d{3})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{4})(\\d{4})(\\d{1,4})', format='\\1/\\2 \\3', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{4})(\\d{3})(\\d{3})(\\d{3})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{4})(\\d{2})(\\d{3})(\\d{2})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{4})(\\d{3})(\\d{2})(\\d{2})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{4})(\\d{2})(\\d{2})(\\d{2,3})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))']), NumberFormat(pattern='(\\d{5})(\\d{3})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['3']), NumberFormat(pattern='(\\d{5})(\\d{4})(\\d{3,4})', format='\\1/\\2 \\3', leading_digits_pattern=['3']), NumberFormat(pattern='(\\d{5})(\\d{3})(\\d{3})(\\d{3})', format='\\1/\\2 \\3 \\4', leading_digits_pattern=['3']), NumberFormat(pattern='([18]\\d{2})(\\d{2,3})(\\d{3})(\\d{2})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['1[5-7]|800']), NumberFormat(pattern='(\\d{3})(\\d)(\\d{3})(\\d{3,4})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['180|900[1359]']), NumberFormat(pattern='(\\d{3})(\\d)(\\d{4})(\\d{3,4})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['180|900[1359]']), NumberFormat(pattern='(\\d{4})(\\d{4,10})', format='\\1 \\2', leading_digits_pattern=['180|900[1359]']), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{4})(\\d{2})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['900[1359]'])]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Auto-generated file, do not edit by hand. 55 metadata"""
2+
from ..phonemetadata import NumberFormat
3+
4+
PHONE_ALT_FORMAT_55 = [NumberFormat(pattern='(\\d{2})(\\d{8})', format='\\1 \\2', leading_digits_pattern=['[1-9][1-9]'])]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Auto-generated file, do not edit by hand. 61 metadata"""
2+
from ..phonemetadata import NumberFormat
3+
4+
PHONE_ALT_FORMAT_61 = [NumberFormat(pattern='(1[389]\\d{2})(\\d{2})(\\d{2})(\\d{2})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['1(?:[38]00|90)']), NumberFormat(pattern='(1[389]\\d{2})(\\d{6})', format='\\1 \\2', leading_digits_pattern=['1(?:[38]00|90)']), NumberFormat(pattern='([2378])(\\d{8})', format='\\1 \\2', leading_digits_pattern=['[2378]'])]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Auto-generated file, do not edit by hand. 81 metadata"""
2+
from ..phonemetadata import NumberFormat
3+
4+
PHONE_ALT_FORMAT_81 = [NumberFormat(pattern='(\\d{3})(\\d{2})(\\d{4})', format='\\1-\\2-\\3', leading_digits_pattern=['(?:12|57|99)0']), NumberFormat(pattern='(\\d{3})(\\d{2})(\\d{2})(\\d{2})', format='\\1-\\2-\\3-\\4', leading_digits_pattern=['(?:12|57|99)0']), NumberFormat(pattern='(\\d{3})(\\d{4})(\\d{2})', format='\\1-\\2-\\3', leading_digits_pattern=['(?:12|57|99)0'])]

0 commit comments

Comments
 (0)