Mercurial > libervia-backend
comparison sat/core/sat_main.py @ 3295:9bc3fca290ab
core: findByFeatures type hints
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 09 Jun 2020 06:16:52 +0200 |
parents | 4240b44842bb |
children | 2157880ba3b4 |
comparison
equal
deleted
inserted
replaced
3294:6505e5cc6ab9 | 3295:9bc3fca290ab |
---|---|
21 import os.path | 21 import os.path |
22 import uuid | 22 import uuid |
23 import hashlib | 23 import hashlib |
24 import copy | 24 import copy |
25 from pathlib import Path | 25 from pathlib import Path |
26 from typing import Optional, List, Tuple, Dict | |
26 import sat | 27 import sat |
27 from sat.core.i18n import _, D_, languageSwitch | 28 from sat.core.i18n import _, D_, languageSwitch |
28 from sat.core import patches | 29 from sat.core import patches |
29 patches.apply() | 30 patches.apply() |
30 from twisted.application import service | 31 from twisted.application import service |
1089 return defer.ensureDeferred(self.findByFeatures( | 1090 return defer.ensureDeferred(self.findByFeatures( |
1090 client, namespaces, identities, bare_jids, service, roster, own_jid, | 1091 client, namespaces, identities, bare_jids, service, roster, own_jid, |
1091 local_device)) | 1092 local_device)) |
1092 | 1093 |
1093 async def findByFeatures( | 1094 async def findByFeatures( |
1094 self, client, namespaces, identities=None, bare_jids=False, service=True, | 1095 self, |
1095 roster=True, own_jid=True, local_device=False): | 1096 client: xmpp.SatXMPPEntity, |
1097 namespaces: List[str], | |
1098 identities: Optional[List[Tuple[str, str]]]=None, | |
1099 bare_jids: bool=False, | |
1100 service: bool=True, | |
1101 roster: bool=True, | |
1102 own_jid: bool=True, | |
1103 local_device: bool=False | |
1104 ) -> Tuple[ | |
1105 Dict[jid.JID, Tuple[str, str, str]], | |
1106 Dict[jid.JID, Tuple[str, str, str]], | |
1107 Dict[jid.JID, Tuple[str, str, str]] | |
1108 ]: | |
1096 """Retrieve all services or contacts managing a set a features | 1109 """Retrieve all services or contacts managing a set a features |
1097 | 1110 |
1098 @param namespaces(list[unicode]): features which must be handled | 1111 @param namespaces: features which must be handled |
1099 @param identities(list[tuple[unicode,unicode]], None): if not None or empty, | 1112 @param identities: if not None or empty, |
1100 only keep those identities tuple must by (category, type) | 1113 only keep those identities |
1101 @param bare_jids(bool): retrieve only bare_jids if True | 1114 tuple must be (category, type) |
1115 @param bare_jids: retrieve only bare_jids if True | |
1102 if False, retrieve full jid of connected devices | 1116 if False, retrieve full jid of connected devices |
1103 @param service(bool): if True return service from our roster | 1117 @param service: if True return service from our server |
1104 @param roster(bool): if True, return entities in roster | 1118 @param roster: if True, return entities in roster |
1105 full jid of all matching resources available will be returned | 1119 full jid of all matching resources available will be returned |
1106 @param own_jid(bool): if True, return profile's jid resources | 1120 @param own_jid: if True, return profile's jid resources |
1107 @param local_device(bool): if True, return profile's jid local resource | 1121 @param local_device: if True, return profile's jid local resource |
1108 (i.e. client.jid) | 1122 (i.e. client.jid) |
1109 @return (tuple(dict[jid.JID(), tuple[unicode, unicode, unicode]]*3)): found | 1123 @return: found entities in a tuple with: |
1110 entities in a tuple with: | |
1111 - service entities | 1124 - service entities |
1112 - own entities | 1125 - own entities |
1113 - roster entities | 1126 - roster entities |
1127 Each element is a dict mapping from jid to a tuple with category, type and | |
1128 name of the entity | |
1114 """ | 1129 """ |
1115 assert isinstance(namespaces, list) | 1130 assert isinstance(namespaces, list) |
1116 if not identities: | 1131 if not identities: |
1117 identities = None | 1132 identities = None |
1118 if not namespaces and not identities: | 1133 if not namespaces and not identities: |