Skip to content

Commit 167b714

Browse files
FelixSchwarzakx
authored andcommitted
stop using deprecated ElementTree methods "getchildren()" and "getiterator()"
Both methods were removed in Python 3.9 as mentioned in the release notes: > Methods getchildren() and getiterator() of classes ElementTree and Element in > the ElementTree module have been removed. They were deprecated in Python 3.2. > Use iter(x) or list(x) instead of x.getchildren() and x.iter() or > list(x.iter()) instead of x.getiterator().
1 parent 4ce6f13 commit 167b714

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

scripts/import_cldr.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def parse_calendar_months(data, calendar):
598598
for width in ctxt.findall('monthWidth'):
599599
width_type = width.attrib['type']
600600
widths = ctxts.setdefault(width_type, {})
601-
for elem in width.getiterator():
601+
for elem in width.iter():
602602
if elem.tag == 'month':
603603
_import_type_text(widths, elem, int(elem.attrib['type']))
604604
elif elem.tag == 'alias':
@@ -616,7 +616,7 @@ def parse_calendar_days(data, calendar):
616616
for width in ctxt.findall('dayWidth'):
617617
width_type = width.attrib['type']
618618
widths = ctxts.setdefault(width_type, {})
619-
for elem in width.getiterator():
619+
for elem in width.iter():
620620
if elem.tag == 'day':
621621
_import_type_text(widths, elem, weekdays[elem.attrib['type']])
622622
elif elem.tag == 'alias':
@@ -634,7 +634,7 @@ def parse_calendar_quarters(data, calendar):
634634
for width in ctxt.findall('quarterWidth'):
635635
width_type = width.attrib['type']
636636
widths = ctxts.setdefault(width_type, {})
637-
for elem in width.getiterator():
637+
for elem in width.iter():
638638
if elem.tag == 'quarter':
639639
_import_type_text(widths, elem, int(elem.attrib['type']))
640640
elif elem.tag == 'alias':
@@ -649,7 +649,7 @@ def parse_calendar_eras(data, calendar):
649649
for width in calendar.findall('eras/*'):
650650
width_type = NAME_MAP[width.tag]
651651
widths = eras.setdefault(width_type, {})
652-
for elem in width.getiterator():
652+
for elem in width.iter():
653653
if elem.tag == 'era':
654654
_import_type_text(widths, elem, type=int(elem.attrib.get('type')))
655655
elif elem.tag == 'alias':
@@ -676,7 +676,7 @@ def parse_calendar_periods(data, calendar):
676676
def parse_calendar_date_formats(data, calendar):
677677
date_formats = data.setdefault('date_formats', {})
678678
for format in calendar.findall('dateFormats'):
679-
for elem in format.getiterator():
679+
for elem in format.iter():
680680
if elem.tag == 'dateFormatLength':
681681
type = elem.attrib.get('type')
682682
if _should_skip_elem(elem, type, date_formats):
@@ -696,7 +696,7 @@ def parse_calendar_date_formats(data, calendar):
696696
def parse_calendar_time_formats(data, calendar):
697697
time_formats = data.setdefault('time_formats', {})
698698
for format in calendar.findall('timeFormats'):
699-
for elem in format.getiterator():
699+
for elem in format.iter():
700700
if elem.tag == 'timeFormatLength':
701701
type = elem.attrib.get('type')
702702
if _should_skip_elem(elem, type, time_formats):
@@ -717,7 +717,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
717717
datetime_formats = data.setdefault('datetime_formats', {})
718718
datetime_skeletons = data.setdefault('datetime_skeletons', {})
719719
for format in calendar.findall('dateTimeFormats'):
720-
for elem in format.getiterator():
720+
for elem in format.iter():
721721
if elem.tag == 'dateTimeFormatLength':
722722
type = elem.attrib.get('type')
723723
if _should_skip_elem(elem, type, datetime_formats):
@@ -880,7 +880,7 @@ def parse_interval_formats(data, tree):
880880
interval_formats[None] = elem.text
881881
elif elem.tag == "intervalFormatItem":
882882
skel_data = interval_formats.setdefault(elem.attrib["id"], {})
883-
for item_sub in elem.getchildren():
883+
for item_sub in elem:
884884
if item_sub.tag == "greatestDifference":
885885
skel_data[item_sub.attrib["id"]] = split_interval_pattern(item_sub.text)
886886
else:
@@ -903,7 +903,7 @@ def parse_currency_formats(data, tree):
903903
type = '%s:%s' % (type, curr_length_type)
904904
if _should_skip_elem(elem, type, currency_formats):
905905
continue
906-
for child in elem.getiterator():
906+
for child in elem.iter():
907907
if child.tag == 'alias':
908908
currency_formats[type] = Alias(
909909
_translate_alias(['currency_formats', elem.attrib['type']],

0 commit comments

Comments
 (0)