Skip to content

Commit

Permalink
let custom result renderer print json line for catalog-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
jsheunis committed Jul 14, 2023
1 parent c6a8c80 commit 1ad9049
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions datalad_catalog/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ class MetaTranslate(ValidatedInterface):

_examples_ = []

@staticmethod
def custom_result_renderer(res, **kwargs):
"""This result renderer dumps the value of the 'output' key
in the result record in JSON-line format -- only if status==ok"""
ui = ui_switcher.ui
ui.message(json.dumps(
res.get('translated_metadata'),
separators=(',', ':'),
indent=None,
cls=jsEncoder,
))

@staticmethod
# generic handling of command results (logging, rendering, filtering, ...)
@eval_results
Expand Down Expand Up @@ -197,8 +209,6 @@ def __call__(
message=("Metadata successfully translated"),
translated_metadata=translated_meta,
)
ui = ui_switcher.ui
ui.message(json.dumps(translated_meta, cls=jsEncoder))
except Exception as e:
yield get_status_dict(
**res_kwargs,
Expand Down

0 comments on commit 1ad9049

Please sign in to comment.