mirror of
https://github.com/CodedotAl/gpt-code-clippy.git
synced 2024-08-16 10:20:28 +03:00
Commiting initial scripts for generating repos with loose licenses
This commit is contained in:
parent
c551b5b1a0
commit
c3a5ae156a
File diff suppressed because one or more lines are too long
31
scripts/get_license_info.py
Normal file
31
scripts/get_license_info.py
Normal file
@ -0,0 +1,31 @@
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from fastcore.script import *
|
||||
from ghapi.all import GhApi
|
||||
|
||||
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
|
||||
|
||||
|
||||
# Open issue on repo using custom title and body
|
||||
def get_license_info(owner, repo):
|
||||
api = GhApi(owner=owner, repo=repo, token=GITHUB_TOKEN)
|
||||
license = api.licenses.get_for_repo(owner=owner, repo=repo)
|
||||
return license.license.name
|
||||
|
||||
@call_parse
|
||||
def main(repos_path: Param("Path to the csv containing all of the repos", str)):
|
||||
"""
|
||||
Use pandas dataframe from the repos path to open issues in each of them.
|
||||
"""
|
||||
repos_path = Path(repos_path)
|
||||
df = pd.read_csv(repos_path)
|
||||
|
||||
# Loop through repos and get their license
|
||||
licenses = []
|
||||
for _, row in df.iterrows():
|
||||
owner, repo = row["name"].split("/")
|
||||
licenses.append(get_license_info(owner, repo))
|
||||
df["license"] = licenses
|
||||
df.to_csv(repos_path.parent/f"{repos_path.stem}_with_license.csv", index=False)
|
Loading…
Reference in New Issue
Block a user