Skip to content

Commit 4e95375

Browse files
authored
Merge pull request #10 from pythonpe/new-authors-mechanism
New AUTHORS mechanism
2 parents 0ee030b + 2f46416 commit 4e95375

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Ider Delzo(soloidx) <soloidx@gmail.com>
2+
Jean-Pierre Chauvel(hellhound) <jean.pierre@chauvel.org>
3+
Nefi Arroyo(nefi) <nefinef@gmail.com>
4+
Jonathan Bolo(jbolo) <jbolo.des@gmail.com>
5+
Sergio Infante(neosergio) <sergio@infante.io>
6+
Antonio Ognio(gnrfan) <aognio@gmail.com>

authors.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import Tuple
23
from urllib.request import Request, urlopen
34

@@ -10,16 +11,23 @@
1011
f"https://api.github.com/repos/{REPO_OWNER}/{REPO}/contents/"
1112
f"{AUTHORS_FILENAME}?ref={BRANCH}"
1213
)
14+
AUTHORS_FILENAME = "AUTHORS"
15+
AUTHORS_FILEPATH = os.path.join(os.path.dirname(__file__), AUTHORS_FILENAME)
1316

1417

1518
def get_authors() -> Tuple[str, str]:
19+
author_lines = set()
20+
with open(AUTHORS_FILEPATH, "r") as fd:
21+
author_lines = {line for line in fd.readlines()}
22+
1623
req = Request(URL, headers=HEADERS)
1724
with urlopen(req) as fd:
18-
for author_line in fd.readlines():
19-
author_line = author_line.decode("utf-8")
20-
tokens = author_line.split("<")
21-
email = tokens[1].strip()[:-1]
22-
tokens = tokens[0].strip().split("(")
23-
name = tokens[0]
24-
nickname = tokens[1][:-1]
25-
yield (nickname, name, f"mailto:{email}")
25+
author_lines.update({line.decode("utf-8") for line in fd.readlines()})
26+
27+
for author_line in author_lines:
28+
tokens = author_line.split("<")
29+
email = tokens[1].strip()[:-1]
30+
tokens = tokens[0].strip().split("(")
31+
name = tokens[0]
32+
nickname = tokens[1][:-1]
33+
yield (nickname, name, f"mailto:{email}")

0 commit comments

Comments
 (0)