-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
75 lines (60 loc) · 1.75 KB
/
main.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import json
import datetime
import os
import glob
def get_EntIri(data):
return data['object_id']
def get_EntId(data):
return data['object_id'].split('/')[-2]
def get_time():
current = datetime.datetime.utcnow()
return current.isoformat() + 'Z'
def get_EntContent(data):
content = {}
try:
content['provenance'] = data['provenance_domain']
except KeyError:
pass
try:
content['usability'] = data['usability_domain']
except KeyError:
pass
try:
content['description'] = data['description_domain']
except KeyError:
pass
try:
content['execution'] = data['execution_domain']
except KeyError:
pass
try:
content['io'] = data['io_domain']
except KeyError:
pass
try:
content['parametric'] = data['parametric_domain']
except KeyError:
pass
return content
def get_id():
id_list = input("Enter the list of your ids separated by commas").split(',')
return id_list
def get_id_for():
id_for_list = input("Enter the list of your IdFors separated by commas").split(',')
return id_for_list
def create_ldh(jsonfile, author_name):
file = open(jsonfile)
data = json.load(file)
contents = {}
contents['id'] = get_id()
contents['IdFor'] = get_id_for()
contents['entType'] = 'BioCompute Object'
contents['entId'] = get_EntId(data)
contents['entIri'] = get_EntIri(data)
contents['entAliases'] = [contents['entId'], contents['entIri'], contents['entType']]
contents['modifier'] = author_name
contents['modified'] = get_time()
contents['entContent'] = get_EntContent(data)
print(contents)
with open('result.json', 'w') as f:
json.dump(contents, f, indent=4)