def analyses_iter(self, count_per_request=100, **kwargs): """ Iterator over self.analyses. :param count_per_request: :param kwargs: :return: """ logger.debug("Use analysis iterator") kwargs.pop("analysis_id", None) return iterator(func=self.analyses, count_per_request=count_per_request, item_key=None, **kwargs)
def main(): # Create VxCubeApi api = VxCubeApi(api_key=API_KEY, version=2.0) sha256 = set() # Use samples_iter of VxCubeApi for sample in api.samples_iter(): sha256.add(sample.sha256) # Use iterator for sample in iterator(api.samples, count_per_request=100, item_key=None): assert sample.sha256 in sha256 # Use all_items all_sha256 = { s.sha256 for s in all_items(api.samples, count_per_request=100, item_key=None) } assert sha256 == all_sha256 print(sha256)
def test_iterator_with_key(): count = 0 for i, j in enumerate(iterator(iterable_func(100, "i"), count_per_request=9, item_key="i")): count += 1 assert i == j assert count == 100
def test_iterator_without_key(): count = 0 for i, j in enumerate(iterator(iterable_func(100), count_per_request=10, item_key=None)): count += 1 assert i == j assert count == 100
def phone_actions_iter(self, count_per_request=100, search=None): logger.debug("Use phone-action iterator") return iterator(func=self.phone_actions, count_per_request=count_per_request, search=search)
def intents_iter(self, count_per_request=100, search=None): logger.debug("Use intent iterator") return iterator(func=self.intents, count_per_request=count_per_request, search=search)
def apilog_iter(self, count_per_request=100, search=None): logger.debug("Use API-log iterator") return iterator(func=self.apilog, count_per_request=count_per_request, search=search)
def networks_iter(self, count_per_request=100, search=None): logger.debug("Use network iterator") return iterator(func=self.networks, count_per_request=count_per_request, search=search)
def drops_iter(self, count_per_request=100, search=None): logger.debug("Use drop iterator") return iterator(func=self.drops, count_per_request=count_per_request, search=search)