File dict2xml-python3.patch of Package percona-monitoring-plugins
--- a/zabbix/bin/dict2xml.py 2023-06-10 01:45:53.866322087 +0200
+++ b/zabbix/bin/dict2xml.py 2023-06-10 02:37:11.824293835 +0200
@@ -1,4 +1,7 @@
-import collections
+try:
+ from collections.abc import Iterable, Mapping
+except ImportError:
+ from collections import Iterable, Mapping
# Grabbed from https://github.com/delfick/python-dict2xml/blob/master/dict2xml/logic.py
@@ -32,7 +35,7 @@
self.data = data
self.type = self.determine_type()
- if self.type == 'flat' and isinstance(self.data, basestring):
+ if self.type == 'flat' and isinstance(self.data, str):
# Make sure we deal with entities
for entity, replacement in self.entities:
self.data = self.data.replace(entity, replacement)
@@ -85,11 +88,12 @@
* flat : A string or something that isn't iterable or a mapping
"""
data = self.data
- if type(data) in (str, unicode):
+
+ if isinstance(data, str):
return 'flat'
- elif isinstance(data, collections.Mapping):
+ elif isinstance(data, Mapping):
return 'mapping'
- elif isinstance(data, collections.Iterable):
+ elif isinstance(data, Iterable):
return 'iterable'
else:
return 'flat'
@@ -117,7 +121,7 @@
children.append(Node("", self.wrap, item))
else:
- val = unicode(data)
+ val = str(data)
if self.tag:
val = "<%s>%s</%s>" % (self.tag, val, self.tag)