changeset 364:8bd8be6815ab

completed docstrings + use short notation for sets
author Arnaud Joset <info@agayon.be>
date Fri, 03 Nov 2017 13:59:54 +0100
parents a98b3d52c2ff
children 9fbb31ce495b
files sat_pubsub/backend.py sat_pubsub/memory_storage.py sat_pubsub/pgsql_storage.py sat_pubsub/test/test_backend.py
diffstat 4 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/backend.py	Fri Nov 03 13:59:15 2017 +0100
+++ b/sat_pubsub/backend.py	Fri Nov 03 13:59:54 2017 +0100
@@ -276,7 +276,7 @@
     def parseCategories(self, item_elt):
         """Check if item contain an atom entry, and parse categories if possible
 
-        @param item (domish.Element): item to parse
+        @param item_elt (domish.Element): item to parse
         @return (list): list of found categories
         """
         categories = []
@@ -538,6 +538,8 @@
         @param requestor(jid.JID): entity who want to check subscriptions
         @param nodeIdentifier(unicode, None): identifier of the node
             node to get all subscriptions of a service
+        @param pep(bool): True if it's a PEP request
+        @param recipient(jid.JID, None): recipient of the PEP request
         """
         return self.storage.getSubscriptions(requestor, nodeIdentifier, pep, recipient)
 
@@ -627,6 +629,9 @@
         @param nodeIdentifier(unicode): identifier of the pubusb node
         @param schema(domish.Element, None): schema to set
             None to remove schema
+        @param requestor(jid.JID): entity doing the request
+        @param pep(bool): True if it's a PEP request
+        @param recipient(jid.JID, None): recipient of the PEP request
         """
         if not nodeIdentifier:
             return defer.fail(error.NoRootNode())
@@ -1262,6 +1267,7 @@
         if self.backend.supportsGroupBlog():
             self.features.append("groupblog")
 
+
         # if self.backend.supportsPublishModel():       #XXX: this feature is not really described in XEP-0060, we just can see it in examples
         #     self.features.append("publish_model")     #     but it's necessary for microblogging comments (see XEP-0277)
 
@@ -1295,9 +1301,9 @@
         for owner_jid in owners:
             notifications_filtered.append(
                 (owner_jid,
-                 set([pubsub.Subscription(node.nodeIdentifier,
-                                          owner_jid,
-                                          'subscribed')]),
+                 {pubsub.Subscription(node.nodeIdentifier,
+                                      owner_jid,
+                                      'subscribed')},
                  [self.getFullItem(item_data) for item_data in items_data]))
 
         if pep:
@@ -1325,9 +1331,9 @@
             for owner_jid in owners:
                 notifications_filtered.append(
                     (owner_jid,
-                     set([pubsub.Subscription(node.nodeIdentifier,
-                                              owner_jid,
-                                              'subscribed')]),
+                     {pubsub.Subscription(node.nodeIdentifier,
+                                          owner_jid,
+                                          'subscribed')},
                      [item_data.item for item_data in items_data]))
 
             if pep:
--- a/sat_pubsub/memory_storage.py	Fri Nov 03 13:59:15 2017 +0100
+++ b/sat_pubsub/memory_storage.py	Fri Nov 03 13:59:54 2017 +0100
@@ -345,7 +345,7 @@
         try:
             callbacks = self.callbacks[service, nodeIdentifier]
         except KeyError:
-            callbacks = set([callback])
+            callbacks = {callback}
             self.callbacks[service, nodeIdentifier] = callbacks
         else:
             callbacks.add(callback)
--- a/sat_pubsub/pgsql_storage.py	Fri Nov 03 13:59:15 2017 +0100
+++ b/sat_pubsub/pgsql_storage.py	Fri Nov 03 13:59:54 2017 +0100
@@ -83,8 +83,8 @@
 
     @param query: SQL query basis
     @param values: current values to replace in query
-    @param pep: True if we are in PEP mode
-    @param recipient: jid of the recipient
+    @param pep(bool): True if we are in PEP mode
+    @param recipient(jid.JID): jid of the recipient
     @return: query + PEP AND check,
         recipient's bare jid is added to value if needed
     """
@@ -213,6 +213,8 @@
     def getNodeIds(self, pep, recipient, allowed_accesses=None):
         """retrieve ids of existing nodes
 
+        @param pep(bool): True if it's a PEP request
+        @param recipient(jid.JID, None): recipient of the PEP request
         @param allowed_accesses(None, set): only nodes with access
             in this set will be returned
             None to return all nodes
--- a/sat_pubsub/test/test_backend.py	Fri Nov 03 13:59:15 2017 +0100
+++ b/sat_pubsub/test/test_backend.py	Fri Nov 03 13:59:54 2017 +0100
@@ -221,7 +221,7 @@
             subscriber, subscriptions, items = result[-1]
 
             self.assertEquals(OWNER, subscriber)
-            self.assertEquals(set([sub]), subscriptions)
+            self.assertEquals({sub}, subscriptions)
             self.assertEquals([item], items)
 
         self.storage = self.NodeStore({'test': TestNode()})
@@ -254,7 +254,7 @@
             self.assertEquals(1, len(result))
             subscriber, subscriptions, items = result[-1]
             self.assertEquals(OWNER, subscriber)
-            self.assertEquals(set([subRoot]), subscriptions)
+            self.assertEquals({subRoot}, subscriptions)
             self.assertEquals([item], items)
 
         self.storage = self.NodeStore({'test': TestNode(),
@@ -287,7 +287,7 @@
             subscriber, subscriptions, items = result[-1]
 
             self.assertEquals(OWNER, subscriber)
-            self.assertEquals(set([sub, subRoot]), subscriptions)
+            self.assertEquals({sub, subRoot}, subscriptions)
             self.assertEquals([item], items)
 
         self.storage = self.NodeStore({'test': TestNode(),