Add a way to get identities as dict (fixes #3566)
This commit is contained in:
parent
e03b7661c1
commit
4ac41a5250
@ -9,6 +9,7 @@ from typing import (
|
|||||||
Set,
|
Set,
|
||||||
Tuple,
|
Tuple,
|
||||||
Union,
|
Union,
|
||||||
|
Dict,
|
||||||
)
|
)
|
||||||
from slixmpp.xmlstream import ElementBase, ET
|
from slixmpp.xmlstream import ElementBase, ET
|
||||||
|
|
||||||
@ -144,6 +145,25 @@ class DiscoInfo(ElementBase):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def dict_identities(self, lang: Optional[str] = None) -> Set[Dict[str, str]]:
|
||||||
|
"""
|
||||||
|
Return the set of all identities, each one as a dict with
|
||||||
|
category, type, xml_lang, and name keys.
|
||||||
|
|
||||||
|
:param lang: If there is a need to filter identities by lang.
|
||||||
|
"""
|
||||||
|
ids = self.get_identities(lang=lang, dedupe=True)
|
||||||
|
dict_ids = set()
|
||||||
|
for identity in ids:
|
||||||
|
dict_ids.add({
|
||||||
|
'category': identity[0],
|
||||||
|
'type': identity[1],
|
||||||
|
'xml_lang': identity[2],
|
||||||
|
'name': identity[3],
|
||||||
|
})
|
||||||
|
return dict_ids
|
||||||
|
|
||||||
|
|
||||||
def get_identities(self, lang: Optional[str] = None, dedupe: bool = True
|
def get_identities(self, lang: Optional[str] = None, dedupe: bool = True
|
||||||
) -> Iterable[IdentityType]:
|
) -> Iterable[IdentityType]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user