Datasets:

Modalities:
Text
Formats:
json
Languages:
English
Libraries:
Datasets
pandas
License:
michaelmior commited on
Commit
e7ea59f
·
verified ·
1 Parent(s): 784c46c

Don't fetch licenses already found

Browse files
Files changed (1) hide show
  1. get_licenses.py +8 -3
get_licenses.py CHANGED
@@ -42,14 +42,19 @@ def main():
42
  session.mount("http://", adapter)
43
  session.mount("https://", adapter)
44
 
 
 
 
 
 
 
 
45
  with open("repos.csv", "r") as csvfile:
46
  # Count number of rows and reset
47
  reader = csv.DictReader(csvfile)
48
- repos = set(row["repository"] for row in reader)
49
 
50
  for repo in tqdm.tqdm(repos):
51
- # Remove github.com/ from the beginning and fetch the license
52
- repo = repo.split("/", maxsplit=1)[1]
53
  license = get_license(session, repo)
54
  obj = {"repository": repo, "license": license}
55
  json.dump(obj, sys.stdout)
 
42
  session.mount("http://", adapter)
43
  session.mount("https://", adapter)
44
 
45
+ # Get the already fetched repositories if they exist
46
+ fetched_repos = set()
47
+ if os.path.exists("licenses.json"):
48
+ for line in open("licenses.json", "r"):
49
+ obj = json.loads(line)
50
+ fetched_repos.add(obj["repository"])
51
+
52
  with open("repos.csv", "r") as csvfile:
53
  # Count number of rows and reset
54
  reader = csv.DictReader(csvfile)
55
+ repos = set(row["repository"].split("/", maxsplit=1)[1] for row in reader) - fetched_repos
56
 
57
  for repo in tqdm.tqdm(repos):
 
 
58
  license = get_license(session, repo)
59
  obj = {"repository": repo, "license": license}
60
  json.dump(obj, sys.stdout)