swh.lister.gitlab.tasks: Fix range computations

This commit is contained in:
Antoine R. Dumont (@ardumont) 2018-07-12 14:23:14 +02:00
parent a69e576c85
commit 81fd5f9c5d
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
3 changed files with 33 additions and 9 deletions

View file

@ -12,3 +12,14 @@ def get(d, keys):
if v is not None:
return v
return None
def split_range(total_pages, nb_pages):
prev_index = None
for index in range(0, total_pages, nb_pages):
if index is not None and prev_index is not None:
yield prev_index, index
prev_index = index
if index != total_pages:
yield index, total_pages