- commit
- 594c866f42395f5627246c5a031437138e9098db
- parent
- b61b96e681e48cacf7a8393b85c552dff7a89c0d
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-08-04 07:05
use name instead of url for services
Diffstat
| M | project_stats.py | 20 | ++++++++------------ |
| M | sample.yml | 4 | ++-- |
2 files changed, 10 insertions, 14 deletions
diff --git a/project_stats.py b/project_stats.py
@@ -174,9 +174,8 @@ async def get_json(url, user=None, token=None): 174 174 return await resp.json() 175 175 176 176177 -1 async def get_github(url, user=None, token=None):178 -1 api_url = re.sub(179 -1 'https?://github.com', 'https://api.github.com/repos', url)-1 177 async def get_github(name, user=None, token=None): -1 178 api_url = 'https://api.github.com/repos/' + name 180 179 181 180 async def _get_json(url): 182 181 data = await get_json(url, user=user, token=token) @@ -275,8 +274,8 @@ async def get_local(path): 275 274 } 276 275 277 276278 -1 async def get_pypi(url):279 -1 data = await get_json(url + '/json')-1 277 async def get_pypi(name): -1 278 data = await get_json('https://pypi.org/pypi/{}/json'.format(name)) 280 279 return { 281 280 'version': data['info']['version'], 282 281 'description': data['info']['summary'], @@ -322,22 +321,19 @@ async def get_npm(name): 322 321 return data 323 322 324 323325 -1 async def get_travis(url):326 -1 api_url = re.sub(327 -1 'https?://travis-ci.org', 'https://api.travis-ci.org/repos', url)328 -1 data = await get_json(api_url)-1 324 async def get_travis(name): -1 325 data = await get_json('https://api.travis-ci.org/repos/' + name) 329 326 return { 330 327 'description': data['description'], 331 328 'tests': data['last_build_result'] == 0, 332 329 } 333 330 334 331335 -1 async def get_firefox(url):-1 332 async def get_firefox(name): 336 333 def get_us(d, key): 337 334 return d.get(key, {}).get('en-US') 338 335339 -1 api_url = re.sub(340 -1 'mozilla.org/[^/]*/firefox', 'mozilla.org/api/v3/addons', url)-1 336 api_url = 'https://addons.mozilla.org/api/v3/addons/addon/' + name 341 337 data = await get_json(api_url) 342 338 343 339 return {
diff --git a/sample.yml b/sample.yml
@@ -1,5 +1,5 @@ 1 1 projects: 2 2 projects: 3 3 local: .4 -1 github: https://github.com/xi/project-stats5 -1 pypi: https://pypi.python.org/pypi/project-stats-1 4 github: xi/project-stats -1 5 pypi: project-stats