(argv=None, apply_config=True)
Command-line entry.
Command-line entry.
Command - line entry .
def main(argv=None, apply_config=True):
    """Command-line entry."""
    if argv is None:
        argv = sys.argv

    try:
        # Exit on broken pipe.
        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    except AttributeError:  # pragma: no cover
        # SIGPIPE is not available on Windows.
        pass

    try:
        args = parse_args(argv[1:], apply_config=apply_config)

        if args.list_fixes:
            for code, description in sorted(supported_fixes()):
                print('{code} - {description}'.format(
                    code=code, description=description))
            return 0

        if args.files == ['-']:
            assert not args.in_place

            encoding = sys.stdin.encoding or get_encoding()

            # LineEndingWrapper is unnecessary here due to the symmetry between
            # standard in and standard out.
            wrap_output(sys.stdout, encoding=encoding).write(
                fix_code(sys.stdin.read(), args, encoding=encoding))
        else:
            if args.in_place or args.diff:
                args.files = list(set(args.files))
            else:
                assert len(args.files) == 1
                assert not args.recursive

            fix_multiple_files(args.files, args, sys.stdout)
    except KeyboardInterrupt:
        return 1
def main ( argv = None , apply_config = True ) : if argv is None : argv = sys . argv try : # Exit on broken pipe. signal . signal ( signal . SIGPIPE , signal . SIG_DFL ) except AttributeError : # pragma: no cover # SIGPIPE is not available on Windows. pass try : args = parse_args ( argv [ 1 : ] , apply_config = apply_config ) if args . list_fixes : for code , description in sorted ( supported_fixes ( ) ) : print ( '{code} - {description}' . format ( code = code , description = description ) ) return 0 if args . files == [ '-' ] : assert not args . in_place encoding = sys . stdin . encoding or get_encoding ( ) # LineEndingWrapper is unnecessary here due to the symmetry between # standard in and standard out. wrap_output ( sys . stdout , encoding = encoding ) . write ( fix_code ( sys . stdin . read ( ) , args , encoding = encoding ) ) else : if args . in_place or args . diff : args . files = list ( set ( args . files ) ) else : assert len ( args . files ) == 1 assert not args . recursive fix_multiple_files ( args . files , args , sys . stdout ) except KeyboardInterrupt : return 1