Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8394410
utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1016 B
Subscribers
None
utils.py
View Options
# Copyright (C) 2015-2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
requests.utils
import
parse_header_links
from
swh.web.tests.helpers
import
check_api_get_responses
def
scroll_results
(
api_client
,
url
):
"""Iterates through pages of results, and returns them all."""
results
=
[]
while
True
:
rv
=
check_api_get_responses
(
api_client
,
url
,
status_code
=
200
)
results
.
extend
(
rv
.
data
)
if
"Link"
in
rv
:
for
link
in
parse_header_links
(
rv
[
"Link"
]):
if
link
[
"rel"
]
==
"next"
:
# Found link to next page of results
url
=
link
[
"url"
]
break
else
:
# No link with 'rel=next'
break
else
:
# No Link header
break
return
results
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Jun 4, 7:24 PM (6 d, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239382
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment