Add pagination helpers to API ListResources
Review Request #7181 — Created April 7, 2015 and submitted
Instances of API
ListResource
classes can easily iterate through all
pages or through all items of all pages easily via new helper methods.
These methods hide the pagination logic that was being used elsewhere
to manually go through all pages ofListResource
s.All instances of this have been replaced with the new helpers to make
the logic cleaner.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
Can we call this get_pages()? |
david | |
Because this is a generator function, you don't need to catch StopIteration--you can just let it percolate up and whatever … |
david | |
Can we call this get_all()? |
david | |
Missing a trailing period. |
chipx86 | |
"of the same" |
chipx86 | |
Generally speaking, a list comprehension would be better here. Avoids the function call to the lambda and the ones to … |
chipx86 | |
getattr() requires the default parameter if the attribute may not be on the object (which is why we have this … |
chipx86 |
-
Tool: Pyflakes Processed Files: rbtools/commands/status.py rbtools/utils/review_request.py rbtools/api/resource.py rbtools/commands/setup_repo.py rbtools/clients/clearcase.py rbtools/commands/post.py rbtools/utils/repository.py rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py rbtools/utils/review_request.py rbtools/api/resource.py rbtools/commands/setup_repo.py rbtools/clients/clearcase.py rbtools/commands/post.py rbtools/utils/repository.py rbtools/clients/svn.py
-
-
-
-
Generally speaking, a list comprehension would be better here. Avoids the function call to the lambda and the ones to
list()
andfilter()
, and is a little more readable:repositories = [ repo for repo in server.get_repositories().all_items if repo['tool'] == 'Subversion' ]
-
getattr()
requires the default parameter if the attribute may not be on the object (which is why we have thisgetattr()
in the first place).
-
Tool: Pyflakes Processed Files: rbtools/commands/status.py rbtools/utils/review_request.py rbtools/api/resource.py rbtools/commands/setup_repo.py rbtools/clients/clearcase.py rbtools/commands/post.py rbtools/utils/repository.py rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py rbtools/utils/review_request.py rbtools/api/resource.py rbtools/commands/setup_repo.py rbtools/clients/clearcase.py rbtools/commands/post.py rbtools/utils/repository.py rbtools/clients/svn.py