summaryrefslogtreecommitdiff
path: root/python3-babel/0001-py39.patch
blob: d0c594eba5f428859e1489c465219ac256c2e6e6 (plain)
    1 From 167b71421f113e2210e4deefef5020402492e5be Mon Sep 17 00:00:00 2001
    2 From: Felix Schwarz <felix.schwarz@oss.schwarz.eu>
    3 Date: Tue, 5 May 2020 09:58:01 +0200
    4 Subject: [PATCH] stop using deprecated ElementTree methods "getchildren()" and
    5  "getiterator()"
    6 
    7 Both methods were removed in Python 3.9 as mentioned in the release notes:
    8 
    9 > Methods getchildren() and getiterator() of classes ElementTree and Element in
   10 > the ElementTree module have been removed. They were deprecated in Python 3.2.
   11 > Use iter(x) or list(x) instead of x.getchildren() and x.iter() or
   12 > list(x.iter()) instead of x.getiterator().
   13 ---
   14  scripts/import_cldr.py | 18 +++++++++---------
   15  1 file changed, 9 insertions(+), 9 deletions(-)
   16 
   17 diff --git a/scripts/import_cldr.py b/scripts/import_cldr.py
   18 index 8993b68e..2ed3af91 100755
   19 --- a/scripts/import_cldr.py
   20 +++ b/scripts/import_cldr.py
   21 @@ -598,7 +598,7 @@ def parse_calendar_months(data, calendar):
   22          for width in ctxt.findall('monthWidth'):
   23              width_type = width.attrib['type']
   24              widths = ctxts.setdefault(width_type, {})
   25 -            for elem in width.getiterator():
   26 +            for elem in width.iter():
   27                  if elem.tag == 'month':
   28                      _import_type_text(widths, elem, int(elem.attrib['type']))
   29                  elif elem.tag == 'alias':
   30 @@ -616,7 +616,7 @@ def parse_calendar_days(data, calendar):
   31          for width in ctxt.findall('dayWidth'):
   32              width_type = width.attrib['type']
   33              widths = ctxts.setdefault(width_type, {})
   34 -            for elem in width.getiterator():
   35 +            for elem in width.iter():
   36                  if elem.tag == 'day':
   37                      _import_type_text(widths, elem, weekdays[elem.attrib['type']])
   38                  elif elem.tag == 'alias':
   39 @@ -634,7 +634,7 @@ def parse_calendar_quarters(data, calendar):
   40          for width in ctxt.findall('quarterWidth'):
   41              width_type = width.attrib['type']
   42              widths = ctxts.setdefault(width_type, {})
   43 -            for elem in width.getiterator():
   44 +            for elem in width.iter():
   45                  if elem.tag == 'quarter':
   46                      _import_type_text(widths, elem, int(elem.attrib['type']))
   47                  elif elem.tag == 'alias':
   48 @@ -649,7 +649,7 @@ def parse_calendar_eras(data, calendar):
   49      for width in calendar.findall('eras/*'):
   50          width_type = NAME_MAP[width.tag]
   51          widths = eras.setdefault(width_type, {})
   52 -        for elem in width.getiterator():
   53 +        for elem in width.iter():
   54              if elem.tag == 'era':
   55                  _import_type_text(widths, elem, type=int(elem.attrib.get('type')))
   56              elif elem.tag == 'alias':
   57 @@ -676,7 +676,7 @@ def parse_calendar_periods(data, calendar):
   58  def parse_calendar_date_formats(data, calendar):
   59      date_formats = data.setdefault('date_formats', {})
   60      for format in calendar.findall('dateFormats'):
   61 -        for elem in format.getiterator():
   62 +        for elem in format.iter():
   63              if elem.tag == 'dateFormatLength':
   64                  type = elem.attrib.get('type')
   65                  if _should_skip_elem(elem, type, date_formats):
   66 @@ -696,7 +696,7 @@ def parse_calendar_date_formats(data, calendar):
   67  def parse_calendar_time_formats(data, calendar):
   68      time_formats = data.setdefault('time_formats', {})
   69      for format in calendar.findall('timeFormats'):
   70 -        for elem in format.getiterator():
   71 +        for elem in format.iter():
   72              if elem.tag == 'timeFormatLength':
   73                  type = elem.attrib.get('type')
   74                  if _should_skip_elem(elem, type, time_formats):
   75 @@ -717,7 +717,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
   76      datetime_formats = data.setdefault('datetime_formats', {})
   77      datetime_skeletons = data.setdefault('datetime_skeletons', {})
   78      for format in calendar.findall('dateTimeFormats'):
   79 -        for elem in format.getiterator():
   80 +        for elem in format.iter():
   81              if elem.tag == 'dateTimeFormatLength':
   82                  type = elem.attrib.get('type')
   83                  if _should_skip_elem(elem, type, datetime_formats):
   84 @@ -880,7 +880,7 @@ def parse_interval_formats(data, tree):
   85              interval_formats[None] = elem.text
   86          elif elem.tag == "intervalFormatItem":
   87              skel_data = interval_formats.setdefault(elem.attrib["id"], {})
   88 -            for item_sub in elem.getchildren():
   89 +            for item_sub in elem:
   90                  if item_sub.tag == "greatestDifference":
   91                      skel_data[item_sub.attrib["id"]] = split_interval_pattern(item_sub.text)
   92                  else:
   93 @@ -903,7 +903,7 @@ def parse_currency_formats(data, tree):
   94                      type = '%s:%s' % (type, curr_length_type)
   95                  if _should_skip_elem(elem, type, currency_formats):
   96                      continue
   97 -                for child in elem.getiterator():
   98 +                for child in elem.iter():
   99                      if child.tag == 'alias':
  100                          currency_formats[type] = Alias(
  101                              _translate_alias(['currency_formats', elem.attrib['type']],

Generated by cgit