24_deb_pkg_gov/check_contrib_file.py

32 lines
1.2 KiB
Python
Raw Normal View History

2024-01-15 17:55:54 +00:00
import csv
import json
import os
from git import Repo
import shutil
key = os.environ.get('KKEXKEY')
def main():
wd = os.getcwd()
with open("expanded_data_final.csv", "r") as file:
reader = csv.reader(file)
for i, line in enumerate(reader):
print("")
repo_name = line[5].strip().split("/")[-1]
print("on " + repo_name)
repo_url = str(line[5].strip())
temp_dir = "/data/users/mgaughan/kkex_contrib_files_122023/tmp/" + repo_name
try:
Repo.clone_from(repo_url, temp_dir)
except:
print("issue cloning")
continue
if os.path.exists(temp_dir + "/.all-contributorsrc"):
shutil.copyfile(temp_dir + "/.all-contributorsrc", "/data/users/mgaughan/kkex_contrib_files_122023/contributing_lists/" + repo_name + "_contrib.json")
if os.path.exists(temp_dir + "/CONTRIBUTING.md"):
shutil.copyfile(temp_dir + "/CONTRIBUTING.md", "/data/users/mgaughan/kkex_contrib_files_122023/contribute_inst/" + repo_name + "_inst.md")
shutil.rmtree(temp_dir, ignore_errors=True)
if __name__ == "__main__":
main()