comparison sat/plugins/plugin_xep_0300.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents ab2696e34d29
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3039:a1bc34f90fa5 3040:fee60f17ebac
194 for hash_elt in parent.elements(NS_HASHES, "hash"): 194 for hash_elt in parent.elements(NS_HASHES, "hash"):
195 algo = hash_elt.getAttribute("algo") 195 algo = hash_elt.getAttribute("algo")
196 try: 196 try:
197 idx = algos.index(algo) 197 idx = algos.index(algo)
198 except ValueError: 198 except ValueError:
199 log.warning("Proposed {} algorithm is not managed".format(algo)) 199 log.warning(f"Proposed {algo} algorithm is not managed")
200 algo = None 200 algo = None
201 continue 201 continue
202 202
203 if best_algo is None or algos.index(best_algo) < idx: 203 if best_algo is None or algos.index(best_algo) < idx:
204 best_algo = algo 204 best_algo = algo
205 best_value = base64.b64decode(str(hash_elt)) 205 best_value = base64.b64decode(str(hash_elt)).decode('utf-8')
206 206
207 if not hash_elt: 207 if not hash_elt:
208 raise exceptions.NotFound 208 raise exceptions.NotFound
209 if not best_algo or not best_value: 209 if not best_algo or not best_value:
210 raise exceptions.DataError 210 raise exceptions.DataError