summaryrefslogtreecommitdiffstats
path: root/deluge
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2019-06-08 17:23:09 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2019-06-08 21:31:49 +0100
commit957cd5dd9c82ddc75d3bb5626057cbee7b059c2c (patch)
treefdbf0663b4ed92552d7d67c018bc831aee958082 /deluge
parent25087d3f2d321b63e46d59e5076df899bfcdf518 (diff)
downloaddeluge-957cd5dd9c82ddc75d3bb5626057cbee7b059c2c.tar.gz
deluge-957cd5dd9c82ddc75d3bb5626057cbee7b059c2c.tar.bz2
deluge-957cd5dd9c82ddc75d3bb5626057cbee7b059c2c.zip
[Core] Fix SimpleNamespace on Python2
Diffstat (limited to 'deluge')
-rw-r--r--deluge/core/alertmanager.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py
index bf9f6b4c5..2fe42224d 100644
--- a/deluge/core/alertmanager.py
+++ b/deluge/core/alertmanager.py
@@ -28,6 +28,14 @@ from deluge.common import decode_bytes
log = logging.getLogger(__name__)
+try:
+ SimpleNamespace = types.SimpleNamespace # Python 3.3+
+except AttributeError:
+
+ class SimpleNamespace(object): # Python 2.7
+ def __init__(self, **attr):
+ self.__dict__.update(attr)
+
class AlertManager(component.Component):
"""AlertManager fetches and processes libtorrent alerts"""
@@ -126,7 +134,7 @@ class AlertManager(component.Component):
if log.isEnabledFor(logging.DEBUG):
log.debug('Handling alert: %s', alert_type)
# Copy alert attributes
- alert_copy = types.SimpleNamespace(
+ alert_copy = SimpleNamespace(
**{
attr: getattr(alert, attr)
for attr in dir(alert)