Fix `diaspy.streams.Generic.full` method in continuation of https://github.com/marekj...
authorCYBERDEViLNL <CYBERDEViLNL@github.com>
Thu, 7 Mar 2019 17:17:08 +0000 (18:17 +0100)
committerCYBERDEViLNL <CYBERDEViLNL@github.com>
Thu, 7 Mar 2019 17:17:08 +0000 (18:17 +0100)
diaspy/streams.py

index 2241c595c95a2af5e256a3b11900082ede610e96..db4d103cec97e27c130a9ea83d467c4883efe625 100644 (file)
@@ -162,54 +162,34 @@ class Generic():
                new_stream = self._obtain(max_time=max_time)
                self._expand(new_stream)
 
-       def full(self, backtime=86400, retry=42, callback=None):
+       def full(self, backtime=None, retry=None, callback=None):
                """Fetches full stream - containing all posts.
                WARNING: this is a **VERY** long running function.
                Use callback parameter to access information about the stream during its
                run.
 
-               Default backtime is one day. But sometimes user might not have any activity for longer
-               period (in the beginning of my D* activity I was posting once a month or so).
-               The role of retry is to hadle such situations by trying to go further back in time.
-               If a post is found the counter is restored.
-
-               Default retry is 42. If you don't know why go to the nearest library (or to the nearest
+               42. If you don't know why go to the nearest library (or to the nearest
                Piratebay mirror) and grab a copy of "A Hitchhiker's Guide to the Galaxy" and read the
                book to find out. This will also increase your level of geekiness and you'll have a
                great time reading the book.
 
-               :param backtime: how many seconds to substract each time
-               :type backtime: int
-               :param retry: how many times the functin should look deeper than your last post
-               :type retry: int
                :param callback: callable taking diaspy.streams.Generic as an argument
                :returns: integer, lenght of the stream
+
+               FIXME backtime and retry deprecations
                """
+               if backtime != None:
+                       print("FIXME: diaspy.streams.Generic.full param backtime is deprecated, it is not needed any more. Please adjust your code.");
+
+               if retry != None:
+                       print("FIXME: diaspy.streams.Generic.full param retry is deprecated, it is needed any more. Please adjust your code.");
+
                oldstream = self.copy()
                self.more()
                while len(oldstream) < len(self):
                        oldstream = self.copy()
                        if callback is not None: callback(self)
-                       self.more(backtime=backtime)
-                       if len(oldstream) < len(self): continue
-                       # but if no posts were found start retrying...
-                       print('[diaspy] retrying... {0}'.format(retry))
-                       n = retry
-                       while n > 0:
-                               # try to get even more posts...
-                               self.more(backtime=backtime)
-                               # check if it was a success...
-                               if len(oldstream) < len(self):
-                                       # and if so restore normal order of execution by
-                                       # going one loop higher
-                                       break
-                               oldstream = self.copy()
-                               # if it was not a success substract one backtime, keep calm and
-                               # try going further back in time...
-                               n -= 1
-                       # check the comment below
-                       # no commented code should be present in good software
-                       #if len(oldstream) == len(self): break
+                       self.more()
                return len(self)
 
        def copy(self):