Skip to content

Commit a352097

Browse files
committed
tools: noInternationalDialling.exampleNumber removed
Upstream v8.9.11 has quietly removed the exampleNumber field from noInternationalDialling entries in the metadata, so update the metadata build job to cope.
1 parent 1fd5fda commit a352097

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

tools/python/buildmetadatafromxml.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def __unicode__(self):
310310

311311
class XPhoneNumberDesc(UnicodeMixin):
312312
"""Parse PhoneNumberDesc object from XML element"""
313-
def __init__(self, xterritory, tag, template=None, general_desc=False):
313+
def __init__(self, xterritory, tag, template=None, has_possible_lengths=True, has_example_number=True):
314314
id = xterritory.attrib['id']
315315
xtag = _get_unique_child(xterritory, tag)
316316
self.xtag = xtag
@@ -340,23 +340,23 @@ def __init__(self, xterritory, tag, template=None, general_desc=False):
340340
else:
341341
raise Exception("Missing required nationalNumberPattern element in %s.%s" % (id, tag))
342342

343-
# An exampleNumber element is present iff this is not the generalDesc
343+
# An exampleNumber element may be present.
344344
example_number = _get_unique_child_value(xtag, 'exampleNumber')
345-
if (not lax) and (not general_desc) and (example_number is None):
345+
if (not lax) and has_example_number and (example_number is None):
346346
raise Exception("Missing required exampleNumber element in %s.%s" % (id, tag))
347-
if general_desc and example_number is not None:
347+
if (not has_example_number) and example_number is not None:
348348
if lax:
349349
example_number = None
350350
else:
351-
raise Exception("Unexpected exampleNumber element for generalDesc in %s.%s" % (id, tag))
351+
raise Exception("Unexpected exampleNumber element in %s.%s" % (id, tag))
352352
self.o.example_number = example_number
353353

354-
# A possibleLengths element is present iff this is not the generalDesc
354+
# A possibleLengths element may be present.
355355
possible_lengths = _get_unique_child(xtag, 'possibleLengths')
356-
if (not lax) and (not general_desc) and (possible_lengths is None):
356+
if (not lax) and has_possible_lengths and (possible_lengths is None):
357357
raise Exception("Missing required possibleLengths element in %s.%s" % (id, tag))
358-
if general_desc and possible_lengths is not None:
359-
raise Exception("Unexpected possibleLengths for generalDesc in %s.%s" % (id, tag))
358+
if (not has_possible_lengths) and possible_lengths is not None:
359+
raise Exception("Unexpected possibleLengths in %s.%s" % (id, tag))
360360
if possible_lengths is not None:
361361
national_lengths = possible_lengths.attrib['national'] # REQUIRED attribute
362362
if national_lengths == "-1":
@@ -430,12 +430,14 @@ def __init__(self, xterritory, short_data):
430430
self.o.leading_zero_possible = get_true_attrib(xterritory, 'leadingZeroPossible')
431431
self.o.mobile_number_portable_region = get_true_attrib(xterritory, 'mobileNumberPortableRegion')
432432

433-
# Retrieve the various PhoneNumberDesc elements, which mostly have the form:
434-
# (nationalNumberPattern, possibleLengths, exampleNumber)
435-
# However the general_desc is first and special; it has form:
433+
# Retrieve the various PhoneNumberDesc elements, which have one of the forms:
434+
# (possibleLengths, exampleNumber, nationalNumberPattern)
435+
# (possibleLengths, nationalNumberPattern)
436436
# (nationalNumberPattern)
437-
# and it will be used to fill out missing fields in many of the other PhoneNumberDesc elements.
438-
self.o.general_desc = XPhoneNumberDesc(xterritory, 'generalDesc', general_desc=True).o
437+
438+
# The general_desc is first and special; it is used to fill out missing fields
439+
# in many of the other PhoneNumberDesc elements.
440+
self.o.general_desc = XPhoneNumberDesc(xterritory, 'generalDesc', has_possible_lengths=False, has_example_number=False).o
439441

440442
self.o.toll_free = XPhoneNumberDesc(xterritory, 'tollFree', template=self.o.general_desc).o
441443
self.o.premium_rate = XPhoneNumberDesc(xterritory, 'premiumRate', template=self.o.general_desc).o
@@ -450,7 +452,7 @@ def __init__(self, xterritory, short_data):
450452
self.o.voip = XPhoneNumberDesc(xterritory, 'voip', template=self.o.general_desc).o
451453
self.o.uan = XPhoneNumberDesc(xterritory, 'uan', template=self.o.general_desc).o
452454
self.o.voicemail = XPhoneNumberDesc(xterritory, 'voicemail', template=self.o.general_desc).o
453-
self.o.no_international_dialling = XPhoneNumberDesc(xterritory, 'noInternationalDialling', template=self.o.general_desc).o
455+
self.o.no_international_dialling = XPhoneNumberDesc(xterritory, 'noInternationalDialling', template=self.o.general_desc, has_example_number=False).o
454456

455457
# Skip noInternationalDialling when combining possible length information
456458
sub_descs = (self.o.toll_free, self.o.premium_rate, self.o.fixed_line, self.o.mobile,

0 commit comments

Comments
 (0)