def read_nanopubs(fn: str) -> Iterable[Mapping[str, Any]]:
jsonl_flag, json_flag, yaml_flag = False, False, False<EOL>if fn == "<STR_LIT:->" or "<STR_LIT>" in fn:<EOL><INDENT>jsonl_flag = True<EOL><DEDENT>elif "<STR_LIT>" in fn:<EOL><INDENT>json_flag = True<EOL><DEDENT>elif re.search("<STR_LIT>", fn):<EOL><INDENT>yaml_flag = True<EOL><DEDENT>else:<EOL><INDENT>log.error("<STR_LIT>")<EOL>return {}<EOL><DEDENT>try:<EOL><INDENT>if re.search("<STR_LIT>", fn):<EOL><INDENT>f = gzip.open(fn, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>f = click.open_file(fn, mode="<STR_LIT>")<EOL><DEDENT>except Exception as e:<EOL><INDENT>log.info(f"<STR_LIT>")<EOL>quit()<EOL><DEDENT><DEDENT>if jsonl_flag:<EOL><INDENT>for line in f:<EOL><INDENT>yield json.loads(line)<EOL><DEDENT><DEDENT>elif json_flag:<EOL><INDENT>nanopubs = json.load(f)<EOL>for nanopub in nanopubs:<EOL><INDENT>yield nanopub<EOL><DEDENT><DEDENT>elif yaml_flag:<EOL><INDENT>nanopubs = yaml.load(f, Loader=yaml.SafeLoader)<EOL>for nanopub in nanopubs:<EOL><INDENT>yield nanopub<EOL><DEDENT><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>log.error(f"<STR_LIT>")<EOL><DEDENT>
Read file and generate nanopubs

    If filename has *.gz, will read as a gzip file
    If filename has *.jsonl*, will parsed as a JSONLines file
    IF filename has *.json*, will be parsed as a JSON file
    If filename has *.yaml* or *.yml*,  will be parsed as a YAML file

    Args:
        filename (str): filename to read nanopubs from

    Returns:
        Generator[Mapping[str, Any]]: generator of nanopubs in nanopub_bel JSON Schema format