File indexing completed on 2025-01-05 04:00:26
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 from lottie.utils.linediff import difflines_str 0013 from lottie.parsers.tgs import parse_tgs_json 0014 0015 0016 parser = argparse.ArgumentParser( 0017 description="Pretty prints two JSON files side by side, highlighting differences (useful to debug / diff lottie files)", 0018 ) 0019 parser.add_argument( 0020 "file1", 0021 help="Left file" 0022 ) 0023 parser.add_argument( 0024 "file2", 0025 help="Right file" 0026 ) 0027 0028 if __name__ == "__main__": 0029 ns = parser.parse_args() 0030 a = parse_tgs_json(ns.file1) 0031 ioa = StringIO() 0032 json.dump(a, ioa, indent=4, sort_keys=True) 0033 0034 b = parse_tgs_json(ns.file2) 0035 iob = StringIO() 0036 json.dump(b, iob, indent=4, sort_keys=True) 0037 0038 difflines_str(ioa.getvalue(), iob.getvalue())