Skip to content

Commit

Permalink
fix(cli): actually flatten 'json-ld' output and remove 'json-ld-graph' (
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Sep 23, 2021
1 parent 2505c9d commit e3acf88
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions renku/core/commands/format/graph.py
Expand Up @@ -32,7 +32,7 @@ def ascii(graph, strict=False):
from ..echo import echo_via_pager

if strict:
raise SHACLValidationError("--strict not supported for json-ld-graph")
raise SHACLValidationError("--strict not supported for ascii")

echo_via_pager(str(DAG(graph)))

Expand Down Expand Up @@ -311,7 +311,7 @@ def makefile(graph, strict=False):
"""Format graph as Makefile."""

if strict:
raise SHACLValidationError("--strict not supported for json-ld-graph")
raise SHACLValidationError("--strict not supported for makefile")

for activity in graph:
if not isinstance(activity, Activity):
Expand All @@ -326,7 +326,7 @@ def makefile(graph, strict=False):

def jsonld(graph, strict=False, to_stdout=True):
"""Format graph as JSON-LD file."""
ld = _jsonld(graph, "expand")
ld = _jsonld(graph, "flatten")

if strict:
r, _, t = validate_graph(ld, format="json-ld")
Expand All @@ -341,13 +341,6 @@ def jsonld(graph, strict=False, to_stdout=True):
return ld


def jsonld_graph(graph, strict=False):
"""Format graph as JSON-LD graph file."""
if strict:
raise SHACLValidationError("--strict not supported for json-ld-graph")
click.echo(_jsonld(graph, "flatten"))


def nt(graph, strict=False):
"""Format graph as n-tuples."""
nt = _conjunctive_graph(graph).serialize(format="nt")
Expand Down Expand Up @@ -383,7 +376,6 @@ def rdf(graph, strict=False):
GRAPH_FORMATS = {
"jsonld": jsonld,
"json-ld": jsonld,
"json-ld-graph": jsonld_graph,
"nt": nt,
"rdf": rdf,
"dot": dot_full,
Expand Down

0 comments on commit e3acf88

Please sign in to comment.