-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9a5bb2
commit 1fc0518
Showing
4 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
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,58 @@ | ||
import sys | ||
import requests | ||
|
||
try: | ||
filename = sys.argv[1] | ||
except IndexError: | ||
print("Usage: contributors.py file.md") | ||
exit(1) | ||
|
||
repo_owner = "rochacbruno" | ||
repo_name = "marmite" | ||
contributors_url = ( | ||
f"https://api.github.com/repos/{repo_owner}/{repo_name}/contributors" | ||
) | ||
|
||
response = requests.get(contributors_url) | ||
if response.status_code != 200: | ||
raise Exception(f"Failed to fetch contributors: {response.status_code}") | ||
|
||
contributors = response.json() | ||
contributors_sorted = reversed( | ||
sorted(contributors, key=lambda user: user["contributions"]) | ||
) | ||
|
||
with open(filename, "w") as file: | ||
file.write("# Contributors\n\n") | ||
|
||
for i, contributor in enumerate(contributors_sorted): | ||
# Start a new grid after every 5 contributors | ||
if i % 5 == 0: | ||
if i != 0: | ||
file.write("</div>\n") | ||
file.write('<div class="grid" style="display: flex;">\n') | ||
|
||
username = contributor["login"] | ||
profile_url = contributor["html_url"] | ||
avatar_url = contributor["avatar_url"] | ||
contributions = contributor["contributions"] | ||
|
||
file.write(' <article style="width: 250px;text-align: center;">\n') | ||
file.write( | ||
' <header style="text-align: center;">' | ||
f'<a href="{profile_url}" target="_blank">' | ||
f"{username}</a></header>\n" | ||
) | ||
file.write( | ||
f' <a href="{profile_url}" target="_blank">' | ||
f'<img src="{avatar_url}" style="width: 100px;"></a>\n' | ||
) | ||
file.write( | ||
' <footer style="text-align: center;">' | ||
f"{contributions} commits</footer>\n" | ||
) | ||
file.write(" </article>\n") | ||
|
||
file.write("</div>\n") | ||
|
||
print("contributors.md file has been generated!") |
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
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
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,36 @@ | ||
# Contributors | ||
|
||
<div class="grid" style="display: flex;"> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/rochacbruno" target="_blank">rochacbruno</a></header> | ||
<a href="https://github.com/rochacbruno" target="_blank"><img src="https://avatars.githubusercontent.com/u/458654?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">63 commits</footer> | ||
</article> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/scovl" target="_blank">scovl</a></header> | ||
<a href="https://github.com/scovl" target="_blank"><img src="https://avatars.githubusercontent.com/u/1684061?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">6 commits</footer> | ||
</article> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/karlamagueta" target="_blank">karlamagueta</a></header> | ||
<a href="https://github.com/karlamagueta" target="_blank"><img src="https://avatars.githubusercontent.com/u/64945344?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">3 commits</footer> | ||
</article> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/rdenadai" target="_blank">rdenadai</a></header> | ||
<a href="https://github.com/rdenadai" target="_blank"><img src="https://avatars.githubusercontent.com/u/917516?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">3 commits</footer> | ||
</article> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/SkySingh04" target="_blank">SkySingh04</a></header> | ||
<a href="https://github.com/SkySingh04" target="_blank"><img src="https://avatars.githubusercontent.com/u/114267538?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">1 commits</footer> | ||
</article> | ||
</div> | ||
<div class="grid" style="display: flex;"> | ||
<article style="width: 250px;text-align: center;"> | ||
<header style="text-align: center;"><a href="https://github.com/zokaibr" target="_blank">zokaibr</a></header> | ||
<a href="https://github.com/zokaibr" target="_blank"><img src="https://avatars.githubusercontent.com/u/8548385?v=4" style="width: 100px;"></a> | ||
<footer style="text-align: center;">1 commits</footer> | ||
</article> | ||
</div> |