INNER CODE UNIT · Python
export_stix
infosecB/LOOBins · src/pyloobins/cli.py:99
def export_stix(file_name: str, path: str) -> None:
"""Export the LOOBins STIX bundle file."""
all_loobins = get_loobins()
stix_bundle = LOOBinsGroup(all_loobins)
if path and not os.path.exists(path):
click.echo(
f"The specified path did not exist. "
f"Creating the {file_name} file in the current directory."
)
file_path = path if path and os.path.exists(path) else "./"
with open(os.path.join(file_path, file_name), mode="w+", encoding="utf-8") as f:
f.write(stix_bundle.to_stix_bundle().serialize(pretty=True))
if __name__ == "__main__":
sys.exit(cli())