Created
February 14, 2014 01:56
-
-
Save pydanny/8994494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Things I want to do: