From a318afea3a4894fa32ecd89b1c7d5688708ae8af Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 30 Jan 2014 05:47:14 +0200 Subject: [PATCH] Port update_coreteam.py to Hy. --- scripts/update-coreteam.hy | 37 ++++++++++++++++++++++++++++++++ scripts/update_coreteam.py | 44 -------------------------------------- 2 files changed, 37 insertions(+), 44 deletions(-) create mode 100644 scripts/update-coreteam.hy delete mode 100644 scripts/update_coreteam.py diff --git a/scripts/update-coreteam.hy b/scripts/update-coreteam.hy new file mode 100644 index 0000000..394bbd8 --- /dev/null +++ b/scripts/update-coreteam.hy @@ -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"))) diff --git a/scripts/update_coreteam.py b/scripts/update_coreteam.py deleted file mode 100644 index 90f2d86..0000000 --- a/scripts/update_coreteam.py +++ /dev/null @@ -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')