summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-05 19:10:52 +0100
committermathieui <mathieui@mathieui.net>2021-02-05 20:08:16 +0100
commitd6ab3124cea389bc72d465cfe7a4306731eaaaa9 (patch)
tree4be1386a5c6283962d19f8447077b7c94fac9afa
parentcb8d2edc8d604b4f5125d492d27fe68a29c16a6c (diff)
downloadslixmpp-d6ab3124cea389bc72d465cfe7a4306731eaaaa9.tar.gz
slixmpp-d6ab3124cea389bc72d465cfe7a4306731eaaaa9.tar.bz2
slixmpp-d6ab3124cea389bc72d465cfe7a4306731eaaaa9.tar.xz
slixmpp-d6ab3124cea389bc72d465cfe7a4306731eaaaa9.zip
XEP-0084: add integer wrappers for int stanza attributes
-rw-r--r--slixmpp/plugins/xep_0084/stanza.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0084/stanza.py b/slixmpp/plugins/xep_0084/stanza.py
index 4b6370ce..57754265 100644
--- a/slixmpp/plugins/xep_0084/stanza.py
+++ b/slixmpp/plugins/xep_0084/stanza.py
@@ -65,6 +65,35 @@ class Info(ElementBase):
plugin_multi_attrib = 'items'
interfaces = {'bytes', 'height', 'id', 'type', 'url', 'width'}
+ def _get_int(self, name: str) -> int:
+ try:
+ return int(self._get_attr(name))
+ except ValueError:
+ return 0
+
+ def _set_int(self, name: str, value: int):
+ if value not in ('', None):
+ int(value)
+ self._set_attr(name, value)
+
+ def get_bytes(self) -> int:
+ return self._get_int('bytes')
+
+ def _set_bytes(self, value: int):
+ self._set_int('bytes', value)
+
+ def get_height(self) -> int:
+ self._get_int('height')
+
+ def set_height(self, value: int):
+ self._set_int('height', value)
+
+ def get_width(self) -> int:
+ self._get_int(self, 'width')
+
+ def set_width(self, value: int):
+ self._set_int('with', value)
+
class Pointer(ElementBase):
name = 'pointer'