From 5408a911e5995946fe504a3570c8f47f60731019 Mon Sep 17 00:00:00 2001 From: inpos Date: Wed, 9 Mar 2016 16:49:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20alert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libpyrr/headers/alert_h.py | 28 ++++++++++++++++++++++++++++ libpyrr/utils.py | 13 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 libpyrr/headers/alert_h.py create mode 100644 libpyrr/utils.py diff --git a/libpyrr/headers/alert_h.py b/libpyrr/headers/alert_h.py new file mode 100644 index 0000000..09a312e --- /dev/null +++ b/libpyrr/headers/alert_h.py @@ -0,0 +1,28 @@ +from ..utils import Enum + +class Alert(object): + def __init__(self): + self.category_t = Enum({ + 'error_notification': 0x1, + 'peer_notification': 0x2, + 'port_mapping_notification': 0x4, + 'storage_notification': 0x8, + 'tracker_notification': 0x10, + 'debug_notification': 0x20, + 'status_notification': 0x40, + 'progress_notification': 0x80, + 'ip_block_notification': 0x100, + 'performance_warning': 0x200, + 'dht_notification': 0x400, + 'dht_notification': 0x400, + 'session_log_notification': 0x2000, + 'torrent_log_notification': 0x4000, + 'peer_log_notification': 0x8000, + 'incoming_request_notification': 0x10000, + 'dht_log_notification': 0x20000, + 'dht_operation_notification': 0x40000, + 'port_mapping_log_notification': 0x80000, + 'picker_log_notification': 0x100000, + 'all_categories': 0x7fffffff + }) +alert = Alert() \ No newline at end of file diff --git a/libpyrr/utils.py b/libpyrr/utils.py new file mode 100644 index 0000000..a8318a4 --- /dev/null +++ b/libpyrr/utils.py @@ -0,0 +1,13 @@ +class AttrDict(dict): + def __getattr__(self, attr): + return self[attr] + def __setattr__(self, attr, value): + self[attr] = value + +class Enum(dict): + def __getattr__(self, attr): + return self[attr] + def __setattr__(self, attr, value): + pass + def __setitem__(self, k, v): + pass