Skip to content

Commit 63eccd5

Browse files
committed
python3.9 - xml module removed elem.getchildren() method, use list(elem)
1 parent 340ec91 commit 63eccd5

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- add checks for NULL in udev-configure-printer (Fedora #1761097)
44
- github #174 - put back notification about missing pysmbc
55
- update .pot file because of fix #174
6+
- python3.9 - xml module removed elem.getchildren() method, use list(elem)
67

78
1.5.12 changes
89
--------------

cupshelpers/openprinting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def parse_result (status, data, result):
338338
packages = {}
339339
container = driver.find ('packages')
340340
if container is not None:
341-
for arch in container.getchildren ():
341+
for arch in list(container):
342342
rpms = {}
343343
for package in arch.findall ('package'):
344344
rpm = {}
@@ -351,7 +351,7 @@ def parse_result (status, data, result):
351351

352352
repositories = package.find ('repositories')
353353
if repositories is not None:
354-
for pkgsys in repositories.getchildren ():
354+
for pkgsys in list(repositories):
355355
rpm.setdefault('repositories', {})[pkgsys.tag] = pkgsys.text
356356

357357
rpms[package.attrib['file']] = rpm
@@ -363,7 +363,7 @@ def parse_result (status, data, result):
363363
ppds = []
364364
container = driver.find ('ppds')
365365
if container is not None:
366-
for each in container.getchildren ():
366+
for each in list(container):
367367
ppds.append (each.text)
368368

369369
if ppds:

cupshelpers/xmldriverprefs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
def PreferredDrivers (filename):
2929
preferreddrivers = xml.etree.ElementTree.XML (open (filename).read ())
30-
return preferreddrivers.getchildren()
30+
return list(preferreddrivers)
3131

3232
class DeviceIDMatch:
3333
"""
@@ -227,18 +227,18 @@ def load (self, drivertypes):
227227
"""
228228

229229
types = []
230-
for drivertype in drivertypes.getchildren ():
230+
for drivertype in list(drivertypes):
231231
t = DriverType (drivertype.attrib["name"])
232232

233-
for child in drivertype.getchildren ():
233+
for child in list(drivertype):
234234
if child.tag == "ppdname":
235235
t.add_ppd_name (child.attrib["match"])
236236
elif child.tag == "attribute":
237237
t.add_attribute (child.attrib["name"],
238238
child.attrib["match"])
239239
elif child.tag == "deviceid":
240240
deviceid_match = DeviceIDMatch ()
241-
for field in child.getchildren ():
241+
for field in list(child):
242242
if field.tag == "field":
243243
deviceid_match.add_field (field.attrib["name"],
244244
field.attrib["match"])
@@ -414,29 +414,29 @@ def load (self, preferreddrivers):
414414
Load the policy from an XML file.
415415
"""
416416

417-
for printer in preferreddrivers.getchildren ():
417+
for printer in list(preferreddrivers):
418418
ptype = PrinterType ()
419-
for child in printer.getchildren ():
419+
for child in list(printer):
420420
if child.tag == "make-and-model":
421421
ptype.add_make_and_model (child.attrib["match"])
422422
elif child.tag == "deviceid":
423423
deviceid_match = DeviceIDMatch ()
424-
for field in child.getchildren ():
424+
for field in list(child):
425425
if field.tag == "field":
426426
deviceid_match.add_field (field.attrib["name"],
427427
field.attrib["match"])
428428
ptype.add_deviceid_match (deviceid_match)
429429

430430
elif child.tag == "drivers":
431-
for drivertype in child.getchildren ():
431+
for drivertype in list(child):
432432
ptype.add_drivertype_pattern (drivertype.text)
433433

434434
elif child.tag == "avoid":
435-
for drivertype in child.getchildren ():
435+
for drivertype in list(child):
436436
ptype.add_avoidtype_pattern (drivertype.text)
437437

438438
elif child.tag == "blacklist":
439-
for drivertype in child.getchildren ():
439+
for drivertype in list(child):
440440
ptype.add_blacklisted (drivertype.text)
441441

442442
self.ptypes.append (ptype)

xml/validate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ def validate (self):
3535
filename = self._filename
3636
print ("Validating %s" % filename)
3737
preferreddrivers = xml.etree.ElementTree.XML (open (filename).read ())
38-
(drivertypes, preferenceorder) = preferreddrivers.getchildren ()
38+
(drivertypes, preferenceorder) = list(preferreddrivers)
3939
validates = True
4040

4141
names = set()
42-
for drivertype in drivertypes.getchildren ():
42+
for drivertype in list(drivertypes):
4343
name = drivertype.get ("name")
4444
names.add (name)
4545

46-
for printer in preferenceorder.getchildren ():
46+
for printer in list(preferenceorder):
4747
types = []
4848
drivers = printer.find ("drivers")
4949
if drivers is not None:
50-
types.extend (drivers.getchildren ())
50+
types.extend (list(drivers))
5151

5252
blacklist = printer.find ("blacklist")
5353
if blacklist is not None:
54-
types.extend (blacklist.getchildren ())
54+
types.extend (list(blacklist))
5555

5656
for drivertype in types:
5757
pattern = drivertype.text.strip ()

0 commit comments

Comments
 (0)