File indexing completed on 2025-01-05 04:00:26

0001 #!/usr/bin/env python3
0002 
0003 import sys
0004 import os
0005 import argparse
0006 sys.path.insert(0, os.path.join(
0007     os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
0008     "lib"
0009 ))
0010 from lottie.exporters.tgs_validator import TgsValidator, Severity
0011 from lottie import __version__
0012 
0013 
0014 parser = argparse.ArgumentParser(
0015     description="Checks a lottie or tgs file to see if it's compatible with telegram stickers",
0016     formatter_class=argparse.RawTextHelpFormatter
0017 )
0018 parser.add_argument("--version", "-v", action="version", version="%(prog)s - python-lottie " + __version__)
0019 parser.add_argument(
0020     "infile",
0021     help="Input file"
0022 )
0023 parser.add_argument(
0024     "--level", "-l",
0025     choices=list(Severity.__members__.keys()),
0026     help="Error level:\n"
0027     "* Note   : the feature is not officially supported but works regardless\n"
0028     "* Warning: the feature is not supported, might result in different animations than expected\n"
0029     "* Error  : Telegram will not recognize the sticker\n",
0030     default="Note",
0031 )
0032 
0033 
0034 if __name__ == "__main__":
0035     ns = parser.parse_args()
0036     severity = Severity.__members__[ns.level]
0037 
0038     validator = TgsValidator(severity)
0039     validator.check_file(ns.infile)
0040     if validator.errors:
0041         sys.stdout.write("\n".join(map(str, validator.errors))+"\n")
0042         sys.exit(1)