Skip to content

Commit 07859d9

Browse files
authored
Use makerdf from schema-salad, and bump schema salad version to get json-ld context fix. (#159)
1 parent e76ba3d commit 07859d9

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

cwltool/cwlrdf.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,11 @@
11
import json
22
import urlparse
33
from schema_salad.ref_resolver import Loader
4+
from schema_salad.jsonld_context import makerdf
45
from rdflib import Graph, plugin, URIRef
56
from rdflib.serializer import Serializer
67
from typing import Any, Union, Dict, IO
78

8-
def makerdf(workflow, wf, ctx):
9-
# type: (Union[str, unicode], Union[List[Dict[unicode, Any]], Dict[unicode, Any]], Loader.ContextType) -> Graph
10-
prefixes = {}
11-
for k,v in ctx.iteritems():
12-
if isinstance(v, dict):
13-
url = v["@id"]
14-
else:
15-
url = v
16-
doc_url, frg = urlparse.urldefrag(url)
17-
if "/" in frg:
18-
p, _ = frg.split("/")
19-
prefixes[p] = u"%s#%s/" % (doc_url, p)
20-
21-
if isinstance(wf, list):
22-
for entry in wf:
23-
entry["@context"] = ctx
24-
else:
25-
wf["@context"] = ctx
26-
g = Graph().parse(data=json.dumps(wf), format='json-ld', location=workflow)
27-
28-
# Bug in json-ld loader causes @id fields to be added to the graph
29-
for s,p,o in g.triples((None, URIRef("@id"), None)):
30-
g.remove((s, p, o))
31-
32-
for k2,v2 in prefixes.iteritems():
33-
g.namespace_manager.bind(k2, v2)
34-
35-
return g
36-
379
def printrdf(workflow, wf, ctx, sr, stdout):
3810
# type: (Union[str, unicode], Union[List[Dict[unicode, Any]], Dict[unicode, Any]], Loader.ContextType, str, IO[Any]) -> None
3911
stdout.write(makerdf(workflow, wf, ctx).serialize(format=sr))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
'rdflib >= 4.1.0',
4242
'rdflib-jsonld >= 0.3.0',
4343
'shellescape',
44-
'schema-salad==1.14.20160708181155',
44+
'schema-salad==1.16.20160810195039',
4545
'typing'
4646
],
4747
test_suite='tests',

0 commit comments

Comments
 (0)