| # |
| # update-contributors.py |
| # 32blit |
| # |
| # pull contributors from github and update the list |
| # |
| import os |
| import requests |
| |
| # ignore list, these will be removed. Pimoroni staff |
| ignore = ["Gadgetoid"] |
| |
| # nickname list, these conversions will be made. |
| nicknames = { |
| "Daft-Freak": "Charlie Birks (Daft-Freak)", |
| "lenardg": "LenardG" |
| } |
| |
| def checkNickname(contributor): |
| if contributor in nicknames: |
| return nicknames[contributor] |
| return contributor |
| |
| |
| # Start program |
| print("32blit Contributors Updater") |
| print("Downloading contributors from Github ...") |
| |
| r = requests.get('https://api.github.com/repos/32blit/32blit-sdk/contributors', |
| headers = {"Accept": "application/vnd.github.v3+json"}) |
| |
| if r.status_code != 200: |
| print("API returned {0} response. Aborting.".format(r.status_code)) |
| exit() |
| |
| contributors = r.json() |
| |
| contrib_hpp = """// contrib.hpp |
| // 32blit GitHub contributors |
| // |
| // AUTO GENERATED BY FILE |
| // PLEASE DO NOT EDIT BY HAND |
| // |
| // use tools/update-contributors.py |
| // |
| |
| #pragma once |
| """ |
| |
| # Add regular contributors |
| contrib_hpp = contrib_hpp + "static const char *contributors[] = {\n" |
| |
| for c in sorted((contrib["login"] for contrib in contributors if contrib["contributions"] < 100), key=str.casefold): |
| name = checkNickname(c) |
| if name in ignore: |
| continue |
| contrib_hpp = contrib_hpp + " \"{0}\",\n".format(name) |
| #print("{0} with {1} commits".format( c["login"], c["contributions"])) |
| |
| contrib_hpp = contrib_hpp + " nullptr\n};\n" |
| |
| # Add special contributors |
| contrib_hpp = contrib_hpp + "static const char *special_thanks[] = {\n" |
| |
| for c in sorted((contrib["login"] for contrib in contributors if contrib["contributions"] >= 100), key=str.casefold): |
| name = checkNickname(c) |
| if name in ignore: |
| continue |
| contrib_hpp = contrib_hpp + " \"{0}\",\n".format(name) |
| #print("{0} with {1} commits".format( c["login"], c["contributions"])) |
| |
| contrib_hpp = contrib_hpp + " nullptr\n};\n" |
| |
| # Write file to disk |
| filename = os.path.join(os.path.dirname(os.path.realpath(__file__)).replace("tools", "32blit"), "contrib.hpp") |
| |
| h = open(filename, "w") |
| h.write(contrib_hpp) |
| h.close() |
| |
| print("Header '{0}' written".format(filename)) |
| print("Done.") |