Skip to content

Instantly share code, notes, and snippets.

@takluyver
Created July 23, 2011 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takluyver/1101890 to your computer and use it in GitHub Desktop.
Save takluyver/1101890 to your computer and use it in GitHub Desktop.
Get issues from JSON API
import json
from urllib import urlopen
def get_issues(project="ipython/ipython/", state="open"):
f = urlopen("http://github.com/api/v2/json/issues/list/%s%s" % (project, state))
return json.load(f)['issues']
def _parse_datetime(s):
"""Parse dates in the format returned by the Github API"""
return datetime.strptime(s.rpartition(")[0], ")
def issues_closed_since(period=timedelta(days=365), project="ipython/ipython/"):
"""Get all issues closed since a particular point in time. period
can either be a datetime object, or a timedelta object. In the
latter case, it is used as a time before the present."""
allclosed = get_issues(project=project, state='closed')
if isinstance(period, timedelta):
period = datetime.now() - period
return [i for i in allclosed if _parse_datetime(i['closed_at']) > period]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment