- commit
- 01b31e529d99d5797947fc4dcc88839d56bea980
- parent
- 63230a4870bccd550fa8013e50291ea3c79e523f
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-12-17 08:08
reduce number of requests for github tag
Diffstat
| M | project_stats.py | 13 | +------------ |
1 files changed, 1 insertions, 12 deletions
diff --git a/project_stats.py b/project_stats.py
@@ -195,23 +195,12 @@ def get_github(url, user=None, password=None): 195 195 raise requests.HTTPError(data['documentation_url']) 196 196 return data 197 197198 -1 def get_all_pages(url):199 -1 l = []200 -1 new = True201 -1 page = 1202 -1 while new:203 -1 u = url + '?page=%i' % page204 -1 new = _get_json(u)205 -1 l += new206 -1 page += 1207 -1 return l208 -1209 198 api_url = re.sub( 210 199 'https?://github.com', 'https://api.github.com/repos', url) 211 200 data = _get_json(api_url) 212 201 213 202 def get_latest_tag():214 -1 tags = get_all_pages(data['tags_url'])-1 203 tags = _get_json(data['tags_url'] + '?per_page=100') 215 204 tags = [tag['name'] for tag in tags] 216 205 if len(tags) > 0: 217 206 return max(tags, key=lambda tag: tag.lstrip('v'))