diff sat/plugins/plugin_xep_0020.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_0020.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/plugins/plugin_xep_0020.py	Wed Jun 27 20:14:46 2018 +0200
@@ -20,6 +20,7 @@
 from sat.core.i18n import _
 from sat.core.constants import Const as C
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 from sat.core import exceptions
 from twisted.words.xish import domish
@@ -33,7 +34,7 @@
 
 from wokkel import disco, iwokkel, data_form
 
-NS_FEATURE_NEG = 'http://jabber.org/protocol/feature-neg'
+NS_FEATURE_NEG = "http://jabber.org/protocol/feature-neg"
 
 PLUGIN_INFO = {
     C.PI_NAME: "XEP 0020 Plugin",
@@ -42,12 +43,11 @@
     C.PI_PROTOCOLS: ["XEP-0020"],
     C.PI_MAIN: "XEP_0020",
     C.PI_HANDLER: "yes",
-    C.PI_DESCRIPTION: _("""Implementation of Feature Negotiation""")
+    C.PI_DESCRIPTION: _("""Implementation of Feature Negotiation"""),
 }
 
 
 class XEP_0020(object):
-
     def __init__(self, host):
         log.info(_("Plugin XEP_0020 initialization"))
 
@@ -62,7 +62,7 @@
         @raise exceptions.NotFound: no feature element found
         """
         try:
-            feature_elt = elt.elements(NS_FEATURE_NEG, 'feature').next()
+            feature_elt = elt.elements(NS_FEATURE_NEG, "feature").next()
         except StopIteration:
             raise exceptions.NotFound
         return feature_elt
@@ -100,7 +100,11 @@
             values = form.fields[field].values
             result[field] = values[0] if values else None
             if len(values) > 1:
-                log.warning(_(u"More than one value choosed for {}, keeping the first one").format(field))
+                log.warning(
+                    _(
+                        u"More than one value choosed for {}, keeping the first one"
+                    ).format(field)
+                )
         return result
 
     def negotiate(self, feature_elt, name, negotiable_values, namespace):
@@ -126,8 +130,8 @@
         @param options(dict): dict with feature as key and choosed option as value
         @param namespace (None, unicode): form namespace or None to ignore
         """
-        feature_elt = domish.Element((NS_FEATURE_NEG, 'feature'))
-        x_form = data_form.Form('submit', formNamespace=namespace)
+        feature_elt = domish.Element((NS_FEATURE_NEG, "feature"))
+        x_form = data_form.Form("submit", formNamespace=namespace)
         x_form.makeFields(options)
         feature_elt.addChild(x_form.toElement())
         return feature_elt
@@ -138,11 +142,16 @@
         @param options_dict(dict): dict with feature as key and iterable of acceptable options as value
         @param namespace(None, unicode): feature namespace
         """
-        feature_elt = domish.Element((NS_FEATURE_NEG, 'feature'))
-        x_form = data_form.Form('form', formNamespace=namespace)
+        feature_elt = domish.Element((NS_FEATURE_NEG, "feature"))
+        x_form = data_form.Form("form", formNamespace=namespace)
         for field in options_dict:
-            x_form.addField(data_form.Field('list-single', field,
-                            options=[data_form.Option(option) for option in options_dict[field]]))
+            x_form.addField(
+                data_form.Field(
+                    "list-single",
+                    field,
+                    options=[data_form.Option(option) for option in options_dict[field]],
+                )
+            )
         feature_elt.addChild(x_form.toElement())
         return feature_elt
 
@@ -150,8 +159,8 @@
 class XEP_0020_handler(XMPPHandler):
     implements(iwokkel.IDisco)
 
-    def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
+    def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
         return [disco.DiscoFeature(NS_FEATURE_NEG)]
 
-    def getDiscoItems(self, requestor, target, nodeIdentifier=''):
+    def getDiscoItems(self, requestor, target, nodeIdentifier=""):
         return []