Created
September 23, 2011 23:04
-
-
Save narfdotpl/1238682 to your computer and use it in GitHub Desktop.
JS game engines by number of watchers
This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
Get list of JavaScript game engines ordered by number of watchers at GitHub. | |
""" | |
import json | |
from BeautifulSoup import BeautifulSoup | |
import requests | |
__author__ = 'Maciej Konieczny <[email protected]>' | |
class Engine(object): | |
def __init__(self, name, repo): | |
self.name = name | |
self.repo = repo | |
self.watchers = None | |
def _main(): | |
# get html | |
url = 'https://github.com/bebraw/jswiki/wiki/Game-Engines' | |
html = requests.get(url).content | |
# get engines' names and repos | |
engines = [] | |
for tr in BeautifulSoup(html)('tbody')[0]('tr'): | |
tds = tr('td') | |
repo_td = tds[-2] | |
if repo_td.text == 'github': | |
name = tds[0].text | |
repo = repo_td('a')[0]['href'].replace('https://github.com/', '') \ | |
.replace('http://github.com/', '') | |
engines.append(Engine(name, repo)) | |
# get watcher numbers | |
api_url = 'https://api.github.com/repos/' | |
for engine in engines: | |
r = requests.get(api_url + engine.repo) | |
if r.status_code == 200: | |
engine.watchers = json.loads(r.content)['watchers'] | |
# remove dead projects | |
engines = filter(lambda x: x.watchers is not None, engines) | |
# sort engines | |
engines.sort(key=lambda x: -x.watchers) | |
# pretty print results | |
get_max_len = lambda attr: max(len(str(getattr(x, attr))) for x in engines) | |
attrs = ['name', 'watchers', 'repo'] | |
template = '{0: >2} {1: <%d} {2: >%d} {3: <%d}' \ | |
% tuple(map(get_max_len, attrs)) | |
for rank, engine in enumerate(engines, start=1): | |
waka_waka = lambda attr: getattr(engine, attr) | |
print template.format(rank, *map(waka_waka, attrs)) | |
if __name__ == '__main__': | |
_main() |
This file contains hidden or 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
# Python >= 2.7 < 3 | |
BeautifulSoup==3.2.0 | |
requests==0.6.1 |
This file contains hidden or 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
JS game engines by number of watchers | |
https://github.com/bebraw/jswiki/wiki/Game-Engines | |
2011-09-24 01:16 | |
1 EaselJS 564 gskinner/EaselJS | |
2 LimeJS 386 digitalfruit/limejs | |
3 gameQuery 208 onaluf/gameQuery | |
4 Crafty 200 louisstow/Crafty | |
5 Cocos2D 180 RyanWilliams/cocos2d-javascript | |
6 MelonJS 133 obiot/melonJS | |
7 xc.js 126 fairfieldt/xcjs | |
8 Mibbu 117 michalbe/mibbu | |
9 GameJs 83 oberhamsi/gamejs | |
10 CAAT 66 hyperandroid/CAAT | |
11 Jaws 56 ippa/jaws | |
12 GammaJS 51 Royce/GammaJS | |
13 Diggy 50 lostdecade/diggy | |
14 Hydrax 32 dionjwa/Hydrax | |
15 FlixelJS 31 BillyWM/FlixelJS | |
16 Hydra 31 aduros/hydra | |
17 Akihabara 28 Akihabara/akihabara | |
18 PropulsionJS 22 calebh/Propulsion | |
19 ingenioJS 12 martensms/ingenioJS | |
20 Rosewood 10 vonkow/Rosewood | |
21 bdge 7 Osmose/bdge | |
22 j5g3 4 giancarlo/j5g3 | |
23 ActionJS 2 neoziro/actionJS | |
24 EntityJS 1 bendangelo/entityjs | |
25 TuteiJS 1 tutei/tuteijs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment