Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0049.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0049.py Wed Jun 27 07:51:29 2018 +0200 +++ b/sat/plugins/plugin_xep_0049.py Wed Jun 27 20:14:46 2018 +0200 @@ -20,12 +20,12 @@ from sat.core.i18n import _ from sat.core.constants import Const as C from sat.core.log import getLogger + log = getLogger(__name__) from wokkel import compat from twisted.words.xish import domish - PLUGIN_INFO = { C.PI_NAME: "XEP-0049 Plugin", C.PI_IMPORT_NAME: "XEP-0049", @@ -34,12 +34,12 @@ C.PI_DEPENDENCIES: [], C.PI_MAIN: "XEP_0049", C.PI_HANDLER: "no", - C.PI_DESCRIPTION: _("""Implementation of private XML storage""") + C.PI_DESCRIPTION: _("""Implementation of private XML storage"""), } class XEP_0049(object): - NS_PRIVATE = 'jabber:iq:private' + NS_PRIVATE = "jabber:iq:private" def __init__(self, host): log.info(_("Plugin XEP-0049 initialization")) @@ -55,7 +55,7 @@ client = self.host.getClient(profile_key) # XXX: feature announcement in disco#info is not mandatory in XEP-0049, so we have to try to use private XML, and react according to the answer iq_elt = compat.IQ(client.xmlstream) - query_elt = iq_elt.addElement('query', XEP_0049.NS_PRIVATE) + query_elt = iq_elt.addElement("query", XEP_0049.NS_PRIVATE) query_elt.addChild(element) return iq_elt.send() @@ -69,13 +69,14 @@ """ client = self.host.getClient(profile_key) # XXX: see privateXMLStore note about feature checking - iq_elt = compat.IQ(client.xmlstream, 'get') - query_elt = iq_elt.addElement('query', XEP_0049.NS_PRIVATE) + iq_elt = compat.IQ(client.xmlstream, "get") + query_elt = iq_elt.addElement("query", XEP_0049.NS_PRIVATE) query_elt.addElement(node_name, namespace) + def getCb(answer_iq_elt): - answer_query_elt = answer_iq_elt.elements(XEP_0049.NS_PRIVATE, 'query').next() + answer_query_elt = answer_iq_elt.elements(XEP_0049.NS_PRIVATE, "query").next() return answer_query_elt.firstChildElement() + d = iq_elt.send() d.addCallback(getCb) return d -