Created
December 18, 2023 19:59
-
-
Save legalsylvain/4dd23e26c3f27305d7f2647851abd590 to your computer and use it in GitHub Desktop.
repo-maintainer-conf parser
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
import yaml | |
import os | |
from selenium import webdriver | |
import urllib | |
members_dict = {} | |
representatives_dict = {} | |
contributors_dict = {} | |
psc_folder = "../repo-maintainer-conf/conf/psc/" | |
psc_files = os.listdir(psc_folder) | |
for psc_file in psc_files: | |
with open(psc_folder + psc_file, 'r') as file: | |
# if psc_file =="vertical.yml": | |
# import pdb; pdb.set_trace() | |
data = yaml.safe_load(file) | |
for key in data.keys(): | |
for member in data[key].get("members", []): | |
if member in members_dict.keys(): | |
members_dict[member] += 1 | |
else: | |
members_dict[member] = 1 | |
if member in contributors_dict.keys(): | |
contributors_dict[member] += 1 | |
else: | |
contributors_dict[member] = 1 | |
for representative in data[key].get("representatives", []): | |
if representative in representatives_dict.keys(): | |
representatives_dict[representative] += 1 | |
else: | |
representatives_dict[representative] = 1 | |
if representative in contributors_dict.keys(): | |
contributors_dict[representative] += 1 | |
else: | |
contributors_dict[representative] = 1 | |
# Save result into local CSV file | |
f = open("contributors.csv", "w") | |
f.writelines(["Contributor, Quantity, Github URL, Contribution URL\n"]) | |
for contributor, quantity in contributors_dict.items(): | |
f.writelines([f"{contributor}, {quantity}, https://github.com/{contributor}, https://ghchart.rshah.org/{contributor}\n"]) | |
f.close() | |
# download each contribution SVG image | |
driver = webdriver.Firefox() | |
for contributor in contributors_dict.keys(): | |
url = f"https://ghchart.rshah.org/{contributor}" | |
print("Dowloading {url} ...") | |
driver.get(url) | |
driver.save_full_page_screenshot(f"contribution_{contributor}") | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment