- commit
- 00e7db2fa05b8717acce693886a8f09131bb2b8a
- parent
- cccc01f77af0c0a7372bab8260f4c4303b8fc868
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-12-13 11:07
add gitlab as source
Diffstat
| M | project_stats.py | 23 | ++++++++++++++++++++++- |
1 files changed, 22 insertions, 1 deletions
diff --git a/project_stats.py b/project_stats.py
@@ -23,7 +23,7 @@ try: 23 23 except ImportError: 24 24 Cheesecake = None 25 2526 -1 SOURCES = ['github', 'gitorious', 'local', 'pypi', 'bower', 'travis']-1 26 SOURCES = ['github', 'gitorious', 'gitlab', 'local', 'pypi', 'bower', 'travis'] 27 27 28 28 KEYS = [ 29 29 'name', @@ -255,6 +255,23 @@ def get_gitorious(url): 255 255 } 256 256 257 257 -1 258 def get_gitlab(_id, token=None): -1 259 api_url = 'https://gitlab.com/api/v3/projects/' + _id -1 260 if token is not None: -1 261 api_url += '?private_token=' + token -1 262 data = get_json(api_url) -1 263 -1 264 return { -1 265 'name': data['name'], -1 266 'description': data['description'], -1 267 'homepage': data['web_url'], -1 268 'created': dt.parse(data['created_at']), -1 269 'updated': dt.parse(data['last_activity_at']), -1 270 'forks_count': data['forks_count'], -1 271 'watchers_count': data['star_count'], -1 272 } -1 273 -1 274 258 275 def get_local(path): 259 276 def git(cmd, *args): 260 277 return subprocess.check_output(['git', '-C', path, cmd] + list(args)) @@ -381,6 +398,10 @@ def get_project(args): 381 398 project[source], 382 399 user=r_get(config, 'github', 'user'), 383 400 password=r_get(config, 'github', 'password')) -1 401 elif source == 'gitlab': -1 402 data = fn( -1 403 project[source], -1 404 token=r_get(config, 'gitlab', 'token')) 384 405 else: 385 406 data = fn(project[source]) 386 407 claims.update(data, source)