#!/usr/bin/env python3 """ Prints an Insta snapshot of ANSI output. Requires pyyaml to be installed. """ import argparse import os import sys from pathlib import Path import yaml def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__) parser.add_argument("snap_file") args = parser.parse_args() content = Path(args.snap_file).read_text() docs = list(yaml.safe_load_all(content)) snap_bytes = bytes(docs[1]) with os.fdopen(sys.stdout.fileno(), "wb", closefd=False) as stdout: stdout.write(snap_bytes) stdout.flush() return 0 if __name__ == "__main__": sys.exit(main())