XEP-0084: add integer wrappers for int stanza attributes
This commit is contained in:
parent
cb8d2edc8d
commit
d6ab3124ce
1 changed files with 29 additions and 0 deletions
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue