<s> from __future__ import unicode_literals <EOL> import argparse <EOL> import os <EOL> import sys <EOL> import pkg_resources <EOL> from pre_commit import color <EOL> from pre_commit import five <EOL> from pre_commit import git <EOL> from pre_commit . commands . autoupdate import autoupdate <EOL> from pre_commit . commands . clean import clean <EOL> from pre_commit . commands . install_uninstall import install <EOL> from pre_commit . commands . install_uninstall import uninstall <EOL> from pre_commit . commands . run import run <EOL> from pre_commit . error_handler import error_handler <EOL> from pre_commit . runner import Runner <EOL> os . environ . pop ( '<STR_LIT>' , None ) <EOL> def main ( argv = None ) : <EOL> argv = argv if argv is not None else sys . argv [ <NUM_LIT:1> : ] <EOL> argv = [ five . to_text ( arg ) for arg in argv ] <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> action = '<STR_LIT:version>' , <EOL> version = '<STR_LIT>' . format ( <EOL> pkg_resources . get_distribution ( '<STR_LIT>' ) . version <EOL> ) <EOL> ) <EOL> subparsers = parser . add_subparsers ( dest = '<STR_LIT>' ) <EOL> install_parser = subparsers . add_parser ( <EOL> '<STR_LIT>' , help = '<STR_LIT>' , <EOL> ) <EOL> install_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> install_parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> ) <EOL> install_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , choices = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> uninstall_parser = subparsers . add_parser ( <EOL> '<STR_LIT>' , help = '<STR_LIT>' , <EOL> ) <EOL> uninstall_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , choices = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> subparsers . add_parser ( <EOL> '<STR_LIT>' , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> run_parser = subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> run_parser . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:?>' , help = '<STR_LIT>' ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , default = '<STR_LIT>' , type = color . use_color , <EOL> metavar = '<STR_LIT:{>' + '<STR_LIT:U+002C>' . join ( color . COLOR_CHOICES ) + '<STR_LIT:}>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> ) <EOL> run_parser . add_argument ( <EOL> '<STR_LIT>' , choices = ( '<STR_LIT>' , '<STR_LIT>' ) , default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> run_mutex_group = run_parser . add_mutually_exclusive_group ( required = False ) <EOL> run_mutex_group . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> run_mutex_group . add_argument ( <EOL> '<STR_LIT>' , nargs = '<STR_LIT:*>' , default = [ ] , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> help = subparsers . add_parser ( <EOL> '<STR_LIT>' , help = '<STR_LIT>' , <EOL> ) <EOL> help . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:?>' , help = '<STR_LIT>' ) <EOL> if len ( argv ) == <NUM_LIT:0> : <EOL> argv = [ '<STR_LIT>' ] <EOL> args = parser . parse_args ( argv ) <EOL> if args . command == '<STR_LIT>' : <EOL> args . files = [ <EOL> os . path . relpath ( os . path . abspath ( filename ) , git . get_root ( ) ) <EOL> for filename in args . files <EOL> ] <EOL> if args . command == '<STR_LIT>' : <EOL> if args . help_cmd : <EOL> parser . parse_args ( [ args . help_cmd , '<STR_LIT>' ] ) <EOL> else : <EOL> parser . parse_args ( [ '<STR_LIT>' ] ) <EOL> with error_handler ( ) : <EOL> runner = Runner . create ( ) <EOL> if args . command == '<STR_LIT>' : <EOL> return install ( <EOL> runner , overwrite = args . overwrite , hooks = args . install_hooks , <EOL> hook_type = args . hook_type , <EOL> ) <EOL> elif args . command == '<STR_LIT>' : <EOL> return uninstall ( runner , hook_type = args . hook_type ) <EOL> elif args . command == '<STR_LIT>' : <EOL> return clean ( runner ) <EOL> elif args . command == '<STR_LIT>' : <EOL> return autoupdate ( runner ) <EOL> elif args . command == '<STR_LIT>' : <EOL> return run ( runner , args ) <EOL> else : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' . format ( args . command ) <EOL> ) <EOL> raise AssertionError ( <EOL> '<STR_LIT>' . format ( args . command ) <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> exit ( main ( ) ) </s>
