forked from rmeloca/EcosystemsAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractLicences.py
More file actions
27 lines (26 loc) · 857 Bytes
/
extractLicences.py
File metadata and controls
27 lines (26 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys
import json
from ecosystemDataManager.ecosystemDataManager import EcosystemDataManager
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage:", sys.argv[0], "<ecosystem> [<licenses>]")
sys.exit(1)
if len(sys.argv) > 2:
licenses = sys.argv[2]
else:
print("licenses not provided. using default.")
licenses = "licenses.json"
try:
with open(licenses) as file:
extracted = json.load(file)
print("licenses loaded")
except Exception as e:
print("licenses not loaded. continuing.")
extracted = []
ecosystem = sys.argv[1]
ecosystemDataManager = EcosystemDataManager(ecosystem)
extracted += [str(license) for license in ecosystemDataManager.getLicenses() if license not in extracted]
with open(licenses, "w") as file:
print("writing")
file.write(json.dumps(extracted, separators=(',\n', ':')))
print("written")