Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination generator with non-default per_page #405

Closed
ericfrederich opened this issue Dec 26, 2017 · 0 comments
Closed

Pagination generator with non-default per_page #405

ericfrederich opened this issue Dec 26, 2017 · 0 comments

Comments

@ericfrederich
Copy link
Contributor

ericfrederich commented Dec 26, 2017

Currently if you request `xxx.list(as_list=False, per_page=100) you end up getting a list instead of the generator.

I think the logic in in http_list needs some rework.
Perhaps just removing the 'per_page' in kwargs condition from here

I should be able to specify something like...

my_generator = gl.projects.list(per_page=100, as_list=False)

... and still get a generator. Then I can hook it up to a progress bar like:

my_generator = gl.projects.list(per_page=100, as_list=False, membership=True)
with click.progressbar(my_generator, length=my_generator.total, label='Projects') as bar:
    for project in bar:
        pass

The above code generates the following error:

AttributeError: 'list' object has no attribute 'total'

Today if I want to use the generator function I have to leave the per_page off and get them only 20 at a time; this makes it much slower.

ericfrederich added a commit to ericfrederich/python-gitlab that referenced this issue Dec 26, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant