docstrings

This commit is contained in:
Kenneth Reitz
2011-03-23 08:30:14 -04:00
parent f2adb9f419
commit 3813267ea7
+37 -2
View File
@@ -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')