kou commented on code in PR #36637:
URL: https://github.com/apache/arrow/pull/36637#discussion_r1261999247
##########
dev/merge_arrow_pr.py:
##########
@@ -78,7 +78,26 @@ def get_json(url, headers=None):
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise ValueError(response.json())
- return response.json()
+ # GitHub returns a link header with the next, previous, last
+ # page if there is pagination on the response. See:
+ #
https://docs.github.com/en/rest/guides/using-pagination-in-the-rest-api#using-link-headers
+ next_responses = None
+ if "link" in response.headers:
+ links = response.headers['link'].split(', ')
+ next_url = None
+ for link in links:
+ if 'rel="next"' in link:
+ # Format: '<url>; rel="next"'
+ next_url = link.split(";")[0][1:-1]
+ if next_url:
+ next_responses = get_json(next_url, headers)
Review Comment:
Can we simplify this?
```suggestion
for link in links:
if 'rel="next"' in link:
# Format: '<url>; rel="next"'
next_url = link.split(";")[0][1:-1]
next_responses = get_json(next_url, headers)
```
##########
dev/merge_arrow_pr.py:
##########
@@ -78,7 +78,26 @@ def get_json(url, headers=None):
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise ValueError(response.json())
- return response.json()
+ # GitHub returns a link header with the next, previous, last
+ # page if there is pagination on the response. See:
+ #
https://docs.github.com/en/rest/guides/using-pagination-in-the-rest-api#using-link-headers
+ next_responses = None
+ if "link" in response.headers:
+ links = response.headers['link'].split(', ')
+ next_url = None
+ for link in links:
+ if 'rel="next"' in link:
+ # Format: '<url>; rel="next"'
+ next_url = link.split(";")[0][1:-1]
+ if next_url:
+ next_responses = get_json(next_url, headers)
+ ret_val = response.json()
Review Comment:
Can we use better name something like `responses`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]