Skip to content

Instantly share code, notes, and snippets.

@dvl
Created March 23, 2016 03:24
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 dvl/6a51cec68ddbb7a96749 to your computer and use it in GitHub Desktop.
Save dvl/6a51cec68ddbb7a96749 to your computer and use it in GitHub Desktop.
Choosing a Go framework with Python...
# -*- coding: utf-8 -*-
import requests
API_URL = 'https://api.github.com/repos/{owner}/{repo}'
client = requests.Session()
client.auth = ('dvl', 'xx')
client.headers.update({
'Accept': 'application/vnd.github.v3+json',
})
repos = [
'albrow/zoom',
'ant0ine/go-json-rest',
'astaxie/beego',
'astaxie/beego',
'bahlo/goat',
'bmizerany/pat',
'codehack/go-relax',
'coocood/qbs',
'cosiner/gomodel',
'cosiner/zerver',
'daryl/zeus',
'desertbit/glue',
'dimfeld/httptreemux',
'dinever/golf',
'gin-gonic/gin',
'go-gorp/gorp',
'go-kit/kit',
'go-macaron/macaron',
'go-ozzo/ozzo-routing',
'go-xorm/xorm',
'go-zoo/bone',
'goanywhere/rex',
'gocraft/web',
'goji/goji',
'googollee/go-socket.io',
'gorilla/mux',
'gorilla/websocket',
'gosuri/go-store',
'hoisie/web',
'husobee/vestigo',
'ian-kent/goose',
'imdario/medeina',
'ivpusic/neo',
'jcuga/golongpoll',
'jinzhu/gorm',
'julienschmidt/httprouter',
'labstack/echo',
'lunny/tango',
'NYTimes/gizmo',
'paulbellamy/mango',
'pilu/traffic',
'pressly/chi',
'rainycape/gondola',
'raphael/goa',
'rcrowley/go-tigertonic',
'resoursea/api',
'revel/revel',
'rs/xmux',
'ungerik/go-rest',
'upper/db',
'VividCortex/siesta',
'volatile/core',
]
stats = []
for repo in repos:
owner, repo = repo.split('/')
url = API_URL.format(owner=owner, repo=repo)
try:
response = client.get(url)
stars = response.json()['stargazers_count']
stats.append((owner, repo, stars))
except:
print(repo, owner)
print(response.text)
stats.sort(key=lambda repo: repo[2], reverse=True)
rows = ''
for owner, repo, stars in stats:
row = '''
<tr>
<td><a href="{url}">{url}</a></td>
<td>{stars}</td>
</tr>'''
url = 'https://github.com/{owner}/{repo}/'.format(owner=owner, repo=repo)
rows += row.format(url=url, stars=stars)
table = '<table border="1">{rows}</table>'.format(rows=rows)
with open('output.html', 'w') as fd:
fd.write(table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment