def _main():
    """
    Main function to execute everything in order
    """
    import argparse
    from pygments.lexers import JsonLexer, XmlLexer
    from pjson.core import format_code, color_yo_shit

    parser = argparse.ArgumentParser(description="Command-line tool to "
                                     "validate and pretty-print JSON and XML")
    parser.add_argument("-x", action="store_true", help="Data is XML")
    parser.add_argument("-b", action="store_true", help="Read data in chunks")
    parser.add_argument("-t", action="store_true", help="Colorize regardless "
                        "if output is a terminal")
    args = parser.parse_args()

    if args.x and args.b:
        sys.stderr.write("-x and -b cannot be used simultaneously\n")
        parser.print_usage(sys.stderr)
        exit(1)

    colorize = args.t or sys.stdout.isatty()

    if args.b:
        for line in sys.stdin:
            text = format_code(line)
            if colorize:
                text = color_yo_shit(text, JsonLexer())
            print(text)
    else:
        data = sys.stdin.read()
        try:
            text = format_code(data, args.x)
            if colorize:
                text = color_yo_shit(text, XmlLexer() if args.x else JsonLexer()).rstrip('\r\n')
            print(text)
        except (__HOLE__, ET.ParseError) as e:
            message = str(e)
            if colorize:
                red = '\x1b[31;m'
                reset_colors = '\x1b[0;m'
                message = ''.join([red, message, reset_colors])
            sys.stderr.write(message+'\n')
            exit(1)
dataset/ETHPy150Open igorgue/pjson/pjson/__init__.py/_main