From df827c121d6e0c30be875c04e2ed67e89f1fbcf0 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Thu, 7 Mar 2019 18:17:08 +0100 Subject: [PATCH] Fix `diaspy.streams.Generic.full` method in continuation of https://github.com/marekjm/diaspy/issues/47 . The `backtime` and `retry` parameters are not needed any more and are now deprecated. --- diaspy/streams.py | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/diaspy/streams.py b/diaspy/streams.py index 2241c59..db4d103 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -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): -- 2.25.1