Skip to content

Commit f87b23c

Browse files
Finish week 40 thu
1 parent 6056bc2 commit f87b23c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stage2.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import re, json
2-
from os import listdir
2+
from os import listdir, path
3+
from pathlib import Path
4+
from shutil import rmtree
35

46
with open('stage1') as file:
57
stage_1_identifiers = file.read().splitlines()
@@ -9,12 +11,19 @@
911
json_file_names.remove('index.json')
1012
json_file_names.sort()
1113

14+
if path.exists('licensedb-licenses'):
15+
rmtree('licensedb-licenses')
16+
Path('licensedb-licenses').mkdir(parents=True, exist_ok=True)
17+
1218
def get_spdx_license_key(json_file_name):
1319
with open ('scancode-licensedb/docs/' + json_file_name, 'r') as file:
1420
json_loader = json.load(file)
1521
spdx_license_key = ''
1622
try:
1723
spdx_license_key = json_loader['spdx_license_key']
24+
25+
file_object = open('licensedb-licenses/' + json_loader['key'] + '.txt', 'w')
26+
file_object.write(json_loader['text'])
1827
except:
1928
print('doesnt have spdx: ' + json_loader['key'])
2029
return spdx_license_key

0 commit comments

Comments
 (0)