@nanopub.command(name="<STR_LIT>", context_settings=CONTEXT_SETTINGS)<EOL>@click.option("<STR_LIT>", "<STR_LIT>")<EOL>@click.option("<STR_LIT>", "<STR_LIT>")<EOL>@pass_context<EOL>def reformat(ctx, input_fn, output_fn):
try:<EOL><INDENT>(<EOL>out_fh,<EOL>yaml_flag,<EOL>jsonl_flag,<EOL>json_flag,<EOL>) = bel.nanopub.files.create_nanopubs_fh(output_fn)<EOL>if yaml_flag or json_flag:<EOL><INDENT>docs = []<EOL><DEDENT>if re.search("<STR_LIT>", input_fn):<EOL><INDENT>f = gzip.open(input_fn, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>f = open(input_fn, "<STR_LIT>")<EOL><DEDENT>for np in bnf.read_nanopubs(input_fn):<EOL><INDENT>if yaml_flag or json_flag:<EOL><INDENT>docs.append(np)<EOL><DEDENT>elif jsonl_flag:<EOL><INDENT>out_fh.write("<STR_LIT>".format(json.dumps(np)))<EOL><DEDENT><DEDENT>if yaml_flag:<EOL><INDENT>yaml.dump(docs, out_fh)<EOL><DEDENT>elif json_flag:<EOL><INDENT>json.dump(docs, out_fh, indent=<NUM_LIT:4>)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>f.close()<EOL>out_fh.close()<EOL><DEDENT>
Reformat between JSON, YAML, JSONLines formats

    \b
    input_fn:
        If input fn has *.gz, will read as a gzip file

    \b
    output_fn:
        If output fn has *.gz, will written as a gzip file
        If output fn has *.jsonl*, will written as a JSONLines file
        IF output fn has *.json*, will be written as a JSON file
        If output fn has *.yaml* or *.yml*,  will be written as a YAML file