Port update_coreteam.py to Hy.

This commit is contained in:
Berker Peksag 2014-01-30 05:47:14 +02:00
parent 4b54e3c748
commit a318afea3a
2 changed files with 37 additions and 44 deletions

View File

@ -0,0 +1,37 @@
;; You need to install the requests package first
(import os.path)
(import requests)
(setv *api-url* "https://api.github.com/{}")
(setv *rst-format* "* `{} <{}>`_")
(setv *missing-names* {"khinsen" "Konrad Hinsen"})
;; We have three concealed members on the hylang organization
;; and GitHub only shows public members if the requester is not
;; an owner of the organization.
(setv *concealed-members* [(, "aldeka" "Karen Rustad")
(, "tuturto" "Tuukka Turto")
(, "cndreisbach" "Clinton N. Dreisbach")])
(defn get-dev-name [login]
(setv name (get (.json (requests.get (.format *api-url* (+ "users/" login)))) "name"))
(if-not name
(.get *missing-names* login)
name))
(setv coredevs (requests.get (.format *api-url* "orgs/hylang/members")))
(setv result (set))
(for [dev (.json coredevs)]
(result.add (.format *rst-format* (get-dev-name (get dev "login"))
(get dev "html_url"))))
(for [(, login name) *concealed-members*]
(result.add (.format *rst-format* name (+ "https://github.com/" login))))
(setv filename (os.path.abspath (os.path.join os.path.pardir
"docs" "coreteam.rst")))
(with [[fobj (open filename "w+")]]
(fobj.write (+ (.join "\n" result) "\n")))

View File

@ -1,44 +0,0 @@
"""
You need to install the requests package first::
$ pip install requests
"""
import os.path
import requests
API_URL = 'https://api.github.com/%s'
RST_FORMAT = '* `%s <%s>`_'
MISSING_NAMES = {
'khinsen': 'Konrad Hinsen',
}
# We have three concealed members on the hylang organization
# and GitHub only shows public members if the requester is not
# an owner of the organization.
CONCEALED_MEMBERS = [
('aldeka', 'Karen Rustad'),
('tuturto', 'Tuukka Turto'),
]
def get_dev_name(login):
name = requests.get(API_URL % 'users/' + login).json()['name']
if not name:
return MISSING_NAMES.get(login)
return name
coredevs = requests.get(API_URL % 'orgs/hylang/members')
result = set()
for dev in coredevs.json():
result.add(RST_FORMAT % (get_dev_name(dev['login']), dev['html_url']))
for login, name in CONCEALED_MEMBERS:
result.add(RST_FORMAT % (name, 'https://github.com/' + login))
filename = os.path.abspath(os.path.join(os.path.pardir,
'docs', 'coreteam.rst'))
with open(filename, 'w+') as fobj:
fobj.write('\n'.join(result) + '\n')