File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 9
9
import io
10
10
import json
11
11
from datetime import datetime
12
+ from pyld import jsonld
13
+
12
14
13
15
14
16
# Environment variables
38
40
# Convert dictionary to metadata json
39
41
metadata = dict_to_metadata (data , flat_compact_crate = False , timestamp = timestamp )
40
42
43
+ try :
44
+ flattened = jsonld .flatten (json .loads (rocrate ))
45
+ #compact against the default schemas:
46
+ default_context = rocratedict ['@context' ]
47
+ #compacted = jsonld.compact(flattened,
48
+ # ctx = ["https://w3id.org/ro/crate/1.1/context",
49
+ # "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld"])
50
+ flat_compacted = jsonld .compact (flattened ,
51
+ ctx = default_context )
52
+
53
+ except :
54
+ flat_compacted = dict_to_metadata (data , flat_compact_crate = True , timestamp = timestamp )
55
+
56
+
41
57
#FOR TESTING - print out dictionary as a comment
42
58
issue .create_comment ("# M@TE crate \n " + str (metadata ))
43
59
44
60
# Move files to repo
45
- model_repo .create_file ("ro-crate-metadata.json" ,"add ro-crate" ,metadata )
61
+ model_repo .create_file ("ro-crate-metadata.json" ,"add ro-crate" ,flat_compacted )
46
62
#we should do this this as part of the copy to website action
47
63
model_repo .create_file ("website_material/ro-crate-metadata.json" ,"add ro-crate" ,metadata )
48
64
You can’t perform that action at this time.
0 commit comments