def get_comments(self): start_permlink = None limit = self.limit comment_count = 0 while True: query_limit = 100 if limit is not None: query_limit = min(limit - comment_count + 1, query_limit) query = Query(start_author=self.username, start_permlink=start_permlink, limit=query_limit) results = Discussions_by_comments(query) if len(results) == 0 or (start_permlink and len(results) == 1): return if comment_count > 0 and start_permlink: results = results[ 1:] # strip duplicates from previous iteration for comment in results: if comment["permlink"] == '': continue comment_count += 1 yield comment start_permlink = comment['permlink'] if comment_count == limit: return
def test_comments(self): bts = self.bts query = Query() query["limit"] = 10 query["filter_tags"] = ["gtg"] query["start_author"] = "gtg" d = Discussions_by_comments(query, steem_instance=bts) self.assertEqual(len(d), 10)
def test_comments(self, node_param): if node_param == "non_appbase": bts = self.bts else: bts = self.appbase query = Query() query["limit"] = 10 query["filter_tags"] = ["gtg"] query["start_author"] = "gtg" d = Discussions_by_comments(query, steem_instance=bts) self.assertEqual(len(d), 10)