Mercurial > libervia-backend
changeset 2774:95321f233387
plugin pubsub schema: code formatting minor update
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 12 Jan 2019 16:50:13 +0100 |
parents | b7974814dd5b |
children | 2dfd5b1d39df |
files | sat/plugins/plugin_exp_pubsub_schema.py sat/plugins/plugin_xep_0315.py |
diffstat | 2 files changed, 30 insertions(+), 82 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_exp_pubsub_schema.py Sat Jan 12 16:49:23 2019 +0100 +++ b/sat/plugins/plugin_exp_pubsub_schema.py Sat Jan 12 16:50:13 2019 +0100 @@ -145,15 +145,8 @@ return d @defer.inlineCallbacks - def getSchemaForm( - self, - client, - service, - nodeIdentifier, - schema=None, - form_type="form", - copy_form=True, - ): + def getSchemaForm(self, client, service, nodeIdentifier, schema=None, + form_type="form", copy_form=True): """get data form from node's schema @param service(None, jid.JID): PubSub service @@ -194,9 +187,8 @@ xmlui = xml_tools.dataForm2XMLUI(form, "") return xmlui - def _getUISchema( - self, service, nodeIdentifier, default_node=None, profile_key=C.PROF_KEY_NONE - ): + def _getUISchema(self, service, nodeIdentifier, default_node=None, + profile_key=C.PROF_KEY_NONE): if not nodeIdentifier: if not default_node: raise ValueError(_(u"nodeIndentifier needs to be set")) @@ -234,18 +226,9 @@ schema_elt.addChild(schema) return iq_elt.send() - def _getDataFormItems( - self, - form_ns="", - service="", - node="", - schema="", - max_items=10, - item_ids=None, - sub_id=None, - extra_dict=None, - profile_key=C.PROF_KEY_NONE, - ): + def _getDataFormItems(self, form_ns="", service="", node="", schema="", max_items=10, + item_ids=None, sub_id=None, extra_dict=None, + profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service = jid.JID(service) if service else None if not node: @@ -274,7 +257,7 @@ @defer.inlineCallbacks def getDataFormItems(self, client, service, nodeIdentifier, schema=None, max_items=None, item_ids=None, sub_id=None, rsm_request=None, - extra=None, default_node=None, form_ns=None, filters=None): + extra=None, default_node=None, form_ns=None, filters=None): """Get items known as being data forms, and convert them to XMLUI @param schema(domish.Element, data_form.Form, None): schema of the node if known @@ -333,16 +316,8 @@ break defer.returnValue((items_xmlui, metadata)) - def _sendDataFormItem( - self, - service, - nodeIdentifier, - values, - schema=None, - item_id=None, - extra=None, - profile_key=C.PROF_KEY_NONE, - ): + def _sendDataFormItem(self, service, nodeIdentifier, values, schema=None, + item_id=None, extra=None, profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service = None if not service else jid.JID(service) if schema: @@ -363,27 +338,20 @@ return d @defer.inlineCallbacks - def sendDataFormItem( - self, - client, - service, - nodeIdentifier, - values, - schema=None, - item_id=None, - extra=None, - deserialise=False, - ): + def sendDataFormItem(self, client, service, nodeIdentifier, values, schema=None, + item_id=None, extra=None, deserialise=False): """Publish an item as a dataform when we know that there is a schema - @param values(dict[key(unicode), [iterable[object], object]]): values set for the form - if not iterable, will be put in a list + @param values(dict[key(unicode), [iterable[object], object]]): values set for the + form. If not iterable, will be put in a list. @param schema(domish.Element, data_form.Form, None): data schema None to retrieve data schema from node (need to do a additional XMPP call) Schema is needed to construct data form to publish - @param deserialise(bool): if True, data are list of unicode and must be deserialized according to expected type - This is done in this method and not directly in _sendDataFormItem because we need to know the data type - which is in the form, not availablable in _sendDataFormItem + @param deserialise(bool): if True, data are list of unicode and must be + deserialized according to expected type. + This is done in this method and not directly in _sendDataFormItem because we + need to know the data type which is in the form, not availablable in + _sendDataFormItem other parameters as the same as for [self._p.sendItem] @return (unicode): id of the created item """ @@ -474,7 +442,8 @@ def prepareBridgeGet(self, service, node, max_items, sub_id, extra_dict, profile_key): """Parse arguments received from bridge *Get methods and return higher level data - @return (tuple): (client, service, node, max_items, extra, sub_id) usable for internal methods + @return (tuple): (client, service, node, max_items, extra, sub_id) usable for + internal methods """ client = self.host.getClient(profile_key) service = jid.JID(service) if service else None @@ -529,7 +498,8 @@ def prepareBridgeSet(self, service, node, schema, item_id, extra, profile_key): """Parse arguments received from bridge *Set methods and return higher level data - @return (tuple): (client, service, node, schema, item_id, extra) usable for internal methods + @return (tuple): (client, service, node, schema, item_id, extra) usable for + internal methods """ client = self.host.getClient(profile_key) service = None if not service else jid.JID(service) @@ -541,19 +511,9 @@ extra[u"update"] = C.bool(extra[u"update"]) return client, service, node or None, schema, item_id or None, extra - def _set( - self, - service, - node, - values, - schema=None, - item_id=None, - extra=None, - default_node=None, - form_ns=None, - fill_author=True, - profile_key=C.PROF_KEY_NONE, - ): + def _set(self, service, node, values, schema=None, item_id=None, extra=None, + default_node=None, form_ns=None, fill_author=True, + profile_key=C.PROF_KEY_NONE): """Bridge method to set item in node with schema this method is a helper so dependant plugins can use it directly @@ -579,20 +539,8 @@ return d @defer.inlineCallbacks - def set( - self, - client, - service, - node, - values, - schema, - item_id, - extra, - deserialise, - form_ns, - default_node=None, - fill_author=True, - ): + def set(self, client, service, node, values, schema, item_id, extra, deserialise, + form_ns, default_node=None, fill_author=True): """Set an item in a node with a schema This method can be used directly by *Set methods added by dependant plugin
--- a/sat/plugins/plugin_xep_0315.py Sat Jan 12 16:49:23 2019 +0100 +++ b/sat/plugins/plugin_xep_0315.py Sat Jan 12 16:50:13 2019 +0100 @@ -33,10 +33,10 @@ C.PI_DEPENDENCIES: [], C.PI_MAIN: "XEP_0315", C.PI_HANDLER: "no", - C.PI_DESCRIPTION: _("""Implementation of Data Forms XML Element"""), + C.PI_DESCRIPTION: _(u"""Implementation of Data Forms XML Element"""), } -NS_XML_ELEMENT = "urn:xmpp:xml-element" +NS_XML_ELEMENT = u"urn:xmpp:xml-element" class Field(data_form.Field):