-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It will be displayed at https://www.psycopg.org/sponsors/
- Loading branch information
Showing
4 changed files
with
185 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
# You can find our sponsors at https://www.psycopg.org/sponsors/ Thank you! | ||
|
||
- username: gporcari | ||
tier: top | ||
avatar: https://avatars2.githubusercontent.com/u/601732?v=4 | ||
name: Giovanni Porcari | ||
|
||
- username: svennek | ||
tier: top | ||
avatar: https://avatars3.githubusercontent.com/u/37837?v=4 | ||
name: Svenne Krap | ||
|
||
- username: pontikos | ||
tier: top | ||
avatar: https://avatars3.githubusercontent.com/u/3852020?v=4 | ||
name: Nikolas Pontikos | ||
|
||
- username: jdatcmd | ||
tier: top | ||
avatar: https://avatars0.githubusercontent.com/u/330373?v=4 | ||
name: Joshua D. Drake | ||
|
||
|
||
- username: taifu | ||
avatar: https://avatars1.githubusercontent.com/u/115712?v=4 | ||
name: Marco Beri | ||
|
||
- username: la-mar | ||
avatar: https://avatars0.githubusercontent.com/u/16618300?v=4 | ||
name: Brock Friedrich | ||
|
||
- username: xarg | ||
avatar: https://avatars2.githubusercontent.com/u/94721?v=4 | ||
name: Alex Plugaru | ||
|
||
- username: rafmagns-skepa-dreag | ||
avatar: https://avatars0.githubusercontent.com/u/7447491?v=4 | ||
name: Richard H | ||
|
||
- username: rustprooflabs | ||
avatar: https://avatars0.githubusercontent.com/u/3085224?v=4 | ||
name: Ryan Lambert | ||
|
||
- username: asqui | ||
avatar: https://avatars3.githubusercontent.com/u/174182?v=4 | ||
name: Daniel Fortunov | ||
|
||
- username: iqbalabd | ||
avatar: https://avatars2.githubusercontent.com/u/14254614?v=4 | ||
name: Iqbal Abdullah | ||
|
||
- username: c-rindi | ||
avatar: https://avatars2.githubusercontent.com/u/7826876?v=4 | ||
name: C~+ | ||
|
||
- username: Intevation | ||
by: bernhardreiter | ||
avatar: https://avatars2.githubusercontent.com/u/2050405?v=4 | ||
name: Intevation |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/env python3 | ||
r"""Add or edit github users in the backers file | ||
""" | ||
|
||
import sys | ||
import logging | ||
import requests | ||
from pathlib import Path | ||
from ruamel.yaml import YAML | ||
|
||
logger = logging.getLogger() | ||
logging.basicConfig( | ||
level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s" | ||
) | ||
|
||
|
||
def fetch_user(username): | ||
logger.info("fetching %s", username) | ||
resp = requests.get( | ||
f"https://api.github.com/users/{username}", | ||
headers={"Accept": "application/vnd.github.v3+json"}, | ||
) | ||
resp.raise_for_status() | ||
return resp.json() | ||
|
||
|
||
def get_user_data(data): | ||
""" | ||
Get the data to save from the request data | ||
""" | ||
return { | ||
"username": data["login"], | ||
"avatar": data["avatar_url"], | ||
"name": data["name"], | ||
} | ||
|
||
|
||
def add_entry(opt, filedata, username): | ||
userdata = get_user_data(fetch_user(username)) | ||
if opt.top: | ||
userdata["tier"] = "top" | ||
|
||
filedata.append(userdata) | ||
|
||
|
||
def update_entry(opt, filedata, entry): | ||
# entry is an username or an user entry daat | ||
if isinstance(entry, str): | ||
username = entry | ||
entry = [e for e in filedata if e["username"] == username] | ||
if not entry: | ||
raise Exception(f"{username} not found") | ||
entry = entry[0] | ||
else: | ||
username = entry["username"] | ||
|
||
userdata = get_user_data(fetch_user(username)) | ||
entry.update(userdata) | ||
|
||
|
||
def main(): | ||
opt = parse_cmdline() | ||
logger.info("reading %s", opt.file) | ||
yaml = YAML(typ="rt") | ||
filedata = yaml.load(opt.file) | ||
|
||
for username in opt.add or (): | ||
add_entry(opt, filedata, username) | ||
|
||
for username in opt.update or (): | ||
update_entry(opt, filedata, username) | ||
|
||
if opt.update_all: | ||
for entry in filedata: | ||
update_entry(opt, filedata, entry) | ||
|
||
# yamllint happy | ||
yaml.explicit_start = True | ||
logger.info("writing %s", opt.file) | ||
yaml.dump(filedata, opt.file) | ||
|
||
|
||
def parse_cmdline(): | ||
from argparse import ArgumentParser | ||
|
||
parser = ArgumentParser(description=__doc__) | ||
parser.add_argument( | ||
"--file", | ||
help="the file to update [default: %(default)s]", | ||
default=Path(__file__).parent.parent / "BACKERS.yaml", | ||
type=Path, | ||
) | ||
parser.add_argument( | ||
"--add", | ||
metavar="USERNAME", | ||
nargs="+", | ||
help="add USERNAME to the backers", | ||
) | ||
|
||
parser.add_argument( | ||
"--top", | ||
action="store_true", | ||
help="add to the top tier", | ||
) | ||
|
||
parser.add_argument( | ||
"--update", | ||
metavar="USERNAME", | ||
nargs="+", | ||
help="update USERNAME data", | ||
) | ||
|
||
parser.add_argument( | ||
"--update-all", | ||
action="store_true", | ||
help="update all the existing backers data", | ||
) | ||
|
||
opt = parser.parse_args() | ||
|
||
return opt | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |