profiler.stop() write_output( options, profiler ) elif options.infile: profiler = Profiler() if options.infile in (b'-','-'): fh = sys.stdin else: fh = codecs.open( options.infile, 'r', 'utf-8') try: content = fh.read() finally: fh.close() profiler.from_json( content ) write_output( options, profiler ) else: parser.print_usage() return parser def stdout_supports_color(): """ Returns True if the running system's terminal supports color, and False otherwise. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py """ plat = sys.platform