Skip to content

Instantly share code, notes, and snippets.

@pydanny
Created February 14, 2014 01:56
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 pydanny/8994494 to your computer and use it in GitHub Desktop.
Save pydanny/8994494 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import codecs
import json
from jinja2 import Template
import requests
# online
url = "https://api.github.com/repos/twoscoops/two-scoops-of-django-1.6/issues"
params = {
"labels": "confirmed",
}
r = requests.get(url, params = params, auth=('pydanny', 'XXXXXXXXXXXXXXXXX'))
data = r.json()
with open("issues.json", "w") as f:
f.write(
json.dumps(data, indent=2)
)
# offline
# with open("issues.json") as f:
# data = json.loads(f.read())
template = Template(u"""
<p>This is the errata page for <a href="http://twoscoopspress.com/products/two-scoops-of-django-1-6">Two Scoops of Django: Best Practices for Django 1.6</a>. Each one of these items was <a href="https://github.com/twoscoops/two-scoops-of-django-1.6/issues">reported</a>
by readers and then confirmed by the authors. We then used a script to pull the confirmed issues here.</p>
<p>This is a work in progress. We'll be updating this page to make it easier to reference.</p>
<ul>
{% for issue in issues %}
<li>
<h3><a href="{{ issue.html_url }}">#{{ issue.number }}</a> {{ issue.title }}</h3>
<p>Reported: {{ issue.created_at }} by: <a href="https://github.com/{{ issue.user.login }}">{{ issue.user.login }}</a></p>
{% set body=issue.body.replace("\n", "<br />") %}
<div>{{ body|safe|urlize }}</div>
</li>
{% endfor %}
</ul>
""")
output = template.render(issues=data)
with codecs.open("issues.html", "w", "utf-8-sig") as f:
f.write(output)
@pydanny
Copy link
Author

pydanny commented Feb 14, 2014

Things I want to do:

  • List all the issues for a repo
  • Filter by 'confirmed' label
  • sort descending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment