File indexing completed on 2025-01-19 03:59:58

0001 #!/usr/bin/env python3
0002 
0003 import sys
0004 import json
0005 from io import StringIO
0006 import os
0007 import argparse
0008 sys.path.insert(0, os.path.join(
0009     os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
0010     "lib"
0011 ))
0012 
0013 from lottie.parsers.tgs import parse_tgs_json
0014 
0015 
0016 parser = argparse.ArgumentParser(
0017     description="Pretty prints a JSON file (or gzipped JSON file), useful to debug / diff lottie files",
0018 )
0019 parser.add_argument(
0020     "infile",
0021     help="Input file"
0022 )
0023 parser.add_argument(
0024     "--no-sort",
0025     action="store_false",
0026     help="Don't sort keys",
0027     dest="sort"
0028 )
0029 
0030 if __name__ == "__main__":
0031     ns = parser.parse_args()
0032     infile = ns.infile
0033     if infile == "-":
0034         infile = sys.stdin
0035     a = parse_tgs_json(infile)
0036     json.dump(a, sys.stdout, indent=4, sort_keys=ns.sort)