def create_nanopubs_fh(output_fn: str):
<EOL>json_flag, jsonl_flag, yaml_flag = False, False, False<EOL>if output_fn:<EOL><INDENT>if re.search("<STR_LIT>", output_fn):<EOL><INDENT>out_fh = gzip.open(output_fn, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>out_fh = click.open_file(output_fn, mode="<STR_LIT>")<EOL><DEDENT>if re.search("<STR_LIT>", output_fn):<EOL><INDENT>yaml_flag = True<EOL><DEDENT>elif "<STR_LIT>" in output_fn or "<STR_LIT:->" == output_fn:<EOL><INDENT>jsonl_flag = True<EOL><DEDENT>elif "<STR_LIT>" in output_fn:<EOL><INDENT>json_flag = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>out_fh = sys.stdout<EOL><DEDENT>return (out_fh, yaml_flag, jsonl_flag, json_flag)<EOL>
Create Nanopubs output filehandle

    \b
    If output fn is '-' will write JSONlines to STDOUT
    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

    Args:
        output_fn: Name of output file

    Returns:
        (filehandle, yaml_flag, jsonl_flag, json_flag)