diff src/plugins/plugin_misc_groupblog.py @ 1423:882e5fabf68c

plugin groupblog, tmp (mam, rsm): some style improvments/fixes: - renamed variables nammed after reserved word/module - removed class variables which are not needed - removed external parenthesis from asserts - in mam.MAMPrefs, removed default value for default argument, as None can't be used - (groupblog) extended docstring for DeferredItems and DeferredItemsFromMany
author Goffi <goffi@goffi.org>
date Thu, 23 Apr 2015 13:35:21 +0200
parents 7c0acb966fd6
children 7f8af1e69812
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Thu Apr 23 10:57:40 2015 +0200
+++ b/src/plugins/plugin_misc_groupblog.py	Thu Apr 23 13:35:21 2015 +0200
@@ -494,33 +494,33 @@
 
     ## get ##
 
-    def _getOrCountComments(self, items, max=0, profile_key=C.PROF_KEY_NONE):
+    def _getOrCountComments(self, items, max_=0, profile_key=C.PROF_KEY_NONE):
         """Get and/or count the comments of the given items.
 
         @param items (list): items to consider.
-        @param max (int): maximum number of comments to get, if 0 only count
+        @param max_ (int): maximum number of comments to get, if 0 only count
             them. The count is set to the item data of key "comments_count".
         @param profile_key (str): %(doc_profile_key)s
         @return: a deferred list of:
-            - if max == 0: microblog data
+            - if max_ == 0: microblog data
             - else: couple (dict, (list[dict], dict)) containing:
                 - microblog data (main item)
                 - couple (comments data, RSM response data for the comments)
         """
         def comments_cb(comments_data, entry):
             entry['comments_count'] = comments_data[1]['count']
-            return (entry, comments_data) if max > 0 else entry
+            return (entry, comments_data) if max_ > 0 else entry
 
-        assert(max >= 0)
+        assert max_ >= 0
         d_list = []
         for entry in items:
             if entry.get('comments', False):
-                comments_rsm = {'max': max}
+                comments_rsm = {'max': max_}
                 d = self.getGroupBlogComments(entry['comments_service'], entry['comments_node'], rsm=comments_rsm, profile_key=profile_key)
                 d.addCallback(comments_cb, entry)
                 d_list.append(d)
             else:
-                if max > 0:
+                if max_ > 0:
                     d_list.append(defer.succeed((entry, ([], {}))))
                 else:
                     d_list.append(defer.succeed(entry))
@@ -588,7 +588,7 @@
         """
         if max_comments is None:
             max_comments = MAX_COMMENTS
-        assert(max_comments > 0)  # otherwise the return signature is not the same
+        assert max_comments > 0  # otherwise the return signature is not the same
         return self._getGroupBlogs(pub_jid_s, item_ids=item_ids, rsm=rsm, max_comments=max_comments, profile_key=profile_key)
 
     def getGroupBlogsAtom(self, pub_jid_s, rsm=None, profile_key=C.PROF_KEY_NONE):
@@ -900,7 +900,7 @@
         self.profile_key = profile_key
 
     def get(self, node, item_ids=None, sub_id=None, rsm=None):
-        """
+        """Retrieve and process a page of pubsub items
 
         @param node (str): node identifier.
         @param item_ids (list[str]): list of items identifiers.
@@ -917,7 +917,7 @@
             profile, client = result
             rsm_ = wokkel_rsm.RSMRequest(**rsm)
             d = self.parent.host.plugins["XEP-0060"].getItems(client.item_access_pubsub,
-                                                              node, rsm_.max_,
+                                                              node, rsm_.max,
                                                               item_ids, sub_id, rsm_,
                                                               profile_key=profile)
 
@@ -948,7 +948,8 @@
         return {publisher: self.parent.getNodeName(publisher) for publisher in jids}
 
     def get(self, publishers_type, publishers, sub_id=None, rsm=None):
-        """
+        """Retrieve and process a page of pubsub items
+
         @param publishers_type (str): type of the list of publishers (one of "GROUP" or "JID" or "ALL")
         @param publishers (list): list of publishers, according to publishers_type (list of groups or list of jids)
         @param sub_id (str): optional subscription identifier.