mirror of
https://github.com/not-kennethreitz/humble.git
synced 2026-06-05 15:10:17 +00:00
docstrings
This commit is contained in:
+37
-2
@@ -1,17 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
humble.cli
|
||||
~~~~~~~~~~
|
||||
|
||||
This module contains the main API interface for Humble.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import json
|
||||
|
||||
from github2.client import Github
|
||||
import requests
|
||||
|
||||
|
||||
github = Github()
|
||||
|
||||
|
||||
__title__ = 'humble'
|
||||
__version__ = '0.1.0'
|
||||
__build__ = 0x000100
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'ISC'
|
||||
__copyright__ = 'Copyright 2011 Kenneth Reitz'
|
||||
__docformat__ = 'restructuredtext'
|
||||
|
||||
|
||||
GITHUB_API = 'http://github.com/api/v1/json/'
|
||||
|
||||
|
||||
|
||||
def get_info_for(username):
|
||||
return github.users.show(username)
|
||||
try:
|
||||
return github.users.show(username)
|
||||
except RuntimeError:
|
||||
return None
|
||||
|
||||
|
||||
def get_repos_for(username):
|
||||
return github.repos.list(username)
|
||||
|
||||
r = requests.get('{0}{1}'.format(GITHUB_API, username))
|
||||
repos = json.loads(r.content).get('user', {}).get('repositories', None)
|
||||
|
||||
def _sort(repo):
|
||||
return repo.get('watchers', '0')
|
||||
|
||||
return sorted(repos, key=_sort, reverse=True)
|
||||
|
||||
|
||||
# print get_repos_for('kennethreitz')
|
||||
|
||||
Reference in New Issue
Block a user