|
| 1 | +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- |
| 2 | +# vi: set ft=python sts=4 ts=4 sw=4 et: |
| 3 | +# |
| 4 | +# Copyright 2021 The NiPreps Developers <[email protected]> |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | +# We support and encourage derived works from this project, please read |
| 19 | +# about our expectations at |
| 20 | +# |
| 21 | +# https://www.nipreps.org/community/licensing/ |
| 22 | +# |
| 23 | +"""Query the GitHub API to retrieve the list of members.""" |
| 24 | + |
| 25 | +import os |
| 26 | +import requests |
| 27 | + |
| 28 | + |
| 29 | +def main(argv=None): |
| 30 | + gh_token = os.getenv("GITHUB_TOKEN", None) |
| 31 | + |
| 32 | + if not gh_token: |
| 33 | + raise RuntimeError("No token") |
| 34 | + |
| 35 | + response = requests.get( |
| 36 | + "https://api.github.com/orgs/nipreps/members?per_page=100", |
| 37 | + headers={ |
| 38 | + "Accept": "application/vnd.github+json", |
| 39 | + "Authorization": f"Bearer {gh_token}", |
| 40 | + } |
| 41 | + ) |
| 42 | + |
| 43 | + if not response.ok: |
| 44 | + raise RuntimeError(f"Response failed ({response.code})") |
| 45 | + |
| 46 | + members = [ |
| 47 | + f'<img class=".avatar" src="{item["avatar_url"}" />' |
| 48 | + for item in response.json() |
| 49 | + ] |
| 50 | + |
| 51 | + print("\n".join(members)) |
| 52 | + |
| 53 | + |
| 54 | +if __name__ == "__main__": |
| 55 | + main() |
0 commit comments