diff sat/plugins/plugin_misc_groupblog.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_misc_groupblog.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/plugins/plugin_misc_groupblog.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 twisted.internet import defer
 from sat.core import exceptions
@@ -32,10 +33,12 @@
 except ImportError:
     from wokkel.subprotocols import XMPPHandler
 
-NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
-NS_GROUPBLOG = 'http://salut-a-toi.org/protocol/groupblog'
-#NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features
-NS_PUBSUB_EXP = NS_PUBSUB  # XXX: we can't use custom namespace as Wokkel's PubSubService use official NS
+NS_PUBSUB = "http://jabber.org/protocol/pubsub"
+NS_GROUPBLOG = "http://salut-a-toi.org/protocol/groupblog"
+# NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features
+NS_PUBSUB_EXP = (
+    NS_PUBSUB
+)  # XXX: we can't use custom namespace as Wokkel's PubSubService use official NS
 NS_PUBSUB_GROUPBLOG = NS_PUBSUB_EXP + "#groupblog"
 NS_PUBSUB_ITEM_CONFIG = NS_PUBSUB_EXP + "#item-config"
 
@@ -48,7 +51,7 @@
     C.PI_DEPENDENCIES: ["XEP-0277"],
     C.PI_MAIN: "GroupBlog",
     C.PI_HANDLER: "yes",
-    C.PI_DESCRIPTION: _("""Implementation of microblogging fine permissions""")
+    C.PI_DESCRIPTION: _("""Implementation of microblogging fine permissions"""),
 }
 
 
@@ -74,7 +77,11 @@
             yield self.host.checkFeatures(client, (NS_PUBSUB_GROUPBLOG,))
         except exceptions.FeatureNotFound:
             client.server_groupblog_available = False
-            log.warning(_(u"Server is not able to manage item-access pubsub, we can't use group blog"))
+            log.warning(
+                _(
+                    u"Server is not able to manage item-access pubsub, we can't use group blog"
+                )
+            )
         else:
             client.server_groupblog_available = True
             log.info(_(u"Server can manage group blogs"))
@@ -85,7 +92,7 @@
         except exceptions.ProfileNotSetError:
             return {}
         try:
-            return {'available': C.boolConst(client.server_groupblog_available)}
+            return {"available": C.boolConst(client.server_groupblog_available)}
         except AttributeError:
             if self.host.isConnected(profile):
                 log.debug("Profile is not connected, service is not checked yet")
@@ -100,7 +107,11 @@
             return
         access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN)
         if access_model == self._p.ACCESS_PUBLISHER_ROSTER:
-            data_format.iter2dict('group', config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, microblog_data)
+            data_format.iter2dict(
+                "group",
+                config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values,
+                microblog_data,
+            )
 
     def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt):
         """Build fine access permission if needed
@@ -108,14 +119,16 @@
         This trigger check if "group*" key are present,
         and create a fine item config to restrict view to these groups
         """
-        groups = list(data_format.dict2iter('group', mb_data))
+        groups = list(data_format.dict2iter("group", mb_data))
         if not groups:
             return
         if not client.server_groupblog_available:
             raise exceptions.CancelError(u"GroupBlog is not available")
         log.debug(u"This entry use group blog")
-        form = data_form.Form('submit', formNamespace=NS_PUBSUB_ITEM_CONFIG)
-        access = data_form.Field(None, self._p.OPT_ACCESS_MODEL, value=self._p.ACCESS_PUBLISHER_ROSTER)
+        form = data_form.Form("submit", formNamespace=NS_PUBSUB_ITEM_CONFIG)
+        access = data_form.Field(
+            None, self._p.OPT_ACCESS_MODEL, value=self._p.ACCESS_PUBLISHER_ROSTER
+        )
         allowed = data_form.Field(None, self._p.OPT_ROSTER_GROUPS_ALLOWED, values=groups)
         form.addField(access)
         form.addField(allowed)
@@ -128,14 +141,16 @@
         """
         if "group" in mb_data:
             options[self._p.OPT_ACCESS_MODEL] = self._p.ACCESS_PUBLISHER_ROSTER
-            options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = list(data_format.dict2iter('group', mb_data))
+            options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = list(
+                data_format.dict2iter("group", mb_data)
+            )
 
 
 class GroupBlog_handler(XMPPHandler):
     implements(iwokkel.IDisco)
 
-    def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
+    def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
         return [disco.DiscoFeature(NS_GROUPBLOG)]
 
-    def getDiscoItems(self, requestor, target, nodeIdentifier=''):
+    def getDiscoItems(self, requestor, target, nodeIdentifier=""):
         return []