Show More
@@ -119,12 +119,13 b' def get_pull_request_files(project, num, auth=False):' | |||
|
119 | 119 | element_pat = re.compile(r'<(.+?)>') |
|
120 | 120 | rel_pat = re.compile(r'rel=[\'"](\w+)[\'"]') |
|
121 | 121 | |
|
122 | def get_paged_request(url, headers=None): | |
|
122 | def get_paged_request(url, headers=None, **params): | |
|
123 | 123 | """get a full list, handling APIv3's paging""" |
|
124 | 124 | results = [] |
|
125 | params.setdefault("per_page", 100) | |
|
125 | 126 | while True: |
|
126 | print("fetching %s" % url, file=sys.stderr) | |
|
127 | response = requests.get(url, headers=headers) | |
|
127 | print("fetching %s with %s" % (url, params), file=sys.stderr) | |
|
128 | response = requests.get(url, headers=headers, params=params) | |
|
128 | 129 | response.raise_for_status() |
|
129 | 130 | results.extend(response.json()) |
|
130 | 131 | if 'next' in response.links: |
@@ -133,28 +134,32 b' def get_paged_request(url, headers=None):' | |||
|
133 | 134 | break |
|
134 | 135 | return results |
|
135 | 136 | |
|
136 |
def get_pulls_list(project, |
|
|
137 | """get pull request list | |
|
138 | """ | |
|
139 |
url = "https://api.github.com/repos/{project}/pulls |
|
|
137 | def get_pulls_list(project, auth=False, **params): | |
|
138 | """get pull request list""" | |
|
139 | params.setdefault("state", "closed") | |
|
140 | url = "https://api.github.com/repos/{project}/pulls".format(project=project) | |
|
140 | 141 | if auth: |
|
141 | 142 | headers = make_auth_header() |
|
142 | 143 | else: |
|
143 | 144 | headers = None |
|
144 | pages = get_paged_request(url, headers=headers) | |
|
145 | pages = get_paged_request(url, headers=headers, params=params) | |
|
145 | 146 | return pages |
|
146 | 147 | |
|
147 |
def get_issues_list(project, |
|
|
148 |
"""get |
|
|
149 | """ | |
|
150 |
url = "https://api.github.com/repos/{project}/ |
|
|
148 | def get_issues_list(project, auth=False, **params): | |
|
149 | """get issues list""" | |
|
150 | params.setdefault("state", "closed") | |
|
151 | url = "https://api.github.com/repos/{project}/issues".format(project=project) | |
|
151 | 152 | if auth: |
|
152 | 153 | headers = make_auth_header() |
|
153 | 154 | else: |
|
154 | 155 | headers = None |
|
155 | pages = get_paged_request(url, headers=headers) | |
|
156 | pages = get_paged_request(url, headers=headers, **params) | |
|
156 | 157 | return pages |
|
157 | 158 | |
|
159 | def is_pull_request(issue): | |
|
160 | """Return True if the given issue is a pull request.""" | |
|
161 | return bool(issue.get('pull_request', {}).get('html_url', None)) | |
|
162 | ||
|
158 | 163 | # encode_multipart_formdata is from urllib3.filepost |
|
159 | 164 | # The only change is to iter_fields, to enforce S3's required key ordering |
|
160 | 165 |
@@ -13,7 +13,7 b' import sys' | |||
|
13 | 13 | |
|
14 | 14 | from datetime import datetime, timedelta |
|
15 | 15 | from subprocess import check_output |
|
16 | from gh_api import get_paged_request, make_auth_header, get_pull_request | |
|
16 | from gh_api import get_paged_request, make_auth_header, get_pull_request, is_pull_request | |
|
17 | 17 | |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | # Globals |
@@ -50,12 +50,6 b' def issues2dict(issues):' | |||
|
50 | 50 | idict[i['number']] = i |
|
51 | 51 | return idict |
|
52 | 52 | |
|
53 | ||
|
54 | def is_pull_request(issue): | |
|
55 | """Return True if the given issue is a pull request.""" | |
|
56 | return bool(issue.get('pull_request', {}).get('html_url', None)) | |
|
57 | ||
|
58 | ||
|
59 | 53 | def split_pulls(all_issues, project="ipython/ipython"): |
|
60 | 54 | """split a list of closed issues into non-PR Issues and Pull Requests""" |
|
61 | 55 | pulls = [] |
General Comments 0
You need to be logged in to leave comments.
Login now