<s> """<STR_LIT>""" <EOL> import argparse <EOL> import runpy <EOL> import sys <EOL> from ivoire import result <EOL> from ivoire . load import load_by_name <EOL> from ivoire . transform import ExampleLoader , transform_possible <EOL> import ivoire <EOL> FORMATTERS = { <EOL> "<STR_LIT>" : result . DotsFormatter , <EOL> } <EOL> class _ExampleNotRunning ( object ) : <EOL> """<STR_LIT>""" <EOL> failureException = None <EOL> group = None <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def should_color ( when ) : <EOL> """<STR_LIT>""" <EOL> if when == "<STR_LIT>" : <EOL> return sys . stderr . isatty ( ) <EOL> return when == "<STR_LIT>" <EOL> def parse ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> if argv is None : <EOL> argv = sys . argv [ <NUM_LIT:1> : ] <EOL> if not argv or argv [ <NUM_LIT:0> ] not in { "<STR_LIT>" , "<STR_LIT>" } : <EOL> argv = [ "<STR_LIT>" ] + argv <EOL> arguments = _clean ( _parser . parse_args ( argv ) ) <EOL> return arguments <EOL> def _clean ( arguments ) : <EOL> if hasattr ( arguments , "<STR_LIT>" ) : <EOL> arguments . color = should_color ( arguments . color ) <EOL> return arguments <EOL> def setup ( config ) : <EOL> """<STR_LIT>""" <EOL> formatter = config . Formatter ( ) <EOL> if config . verbose : <EOL> formatter = result . Verbose ( formatter ) <EOL> if config . color : <EOL> formatter = result . Colored ( formatter ) <EOL> current_result = result . ExampleResult ( formatter ) <EOL> ivoire . current_result = ivoire . _manager . result = current_result <EOL> def run ( config ) : <EOL> """<STR_LIT>""" <EOL> setup ( config ) <EOL> if config . exitfirst : <EOL> ivoire . current_result . failfast = True <EOL> ivoire . current_result . startTestRun ( ) <EOL> for spec in config . specs : <EOL> try : <EOL> load_by_name ( spec ) <EOL> except Exception : <EOL> ivoire . current_result . addError ( <EOL> _ExampleNotRunning ( ) , sys . exc_info ( ) <EOL> ) <EOL> ivoire . current_result . stopTestRun ( ) <EOL> sys . exit ( not ivoire . current_result . wasSuccessful ( ) ) <EOL> def transform ( config ) : <EOL> """<STR_LIT>""" <EOL> if transform_possible : <EOL> ExampleLoader . register ( ) <EOL> args , sys . argv [ <NUM_LIT:1> : ] = sys . argv [ <NUM_LIT:1> : ] , config . args <EOL> try : <EOL> return runpy . run_path ( config . runner , run_name = "<STR_LIT:__main__>" ) <EOL> finally : <EOL> sys . argv [ <NUM_LIT:1> : ] = args <EOL> def main ( argv = None ) : <EOL> arguments = parse ( argv ) <EOL> arguments . func ( arguments ) <EOL> _parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> _subparsers = _parser . add_subparsers ( ) <EOL> _run = _subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> _run . add_argument ( <EOL> "<STR_LIT:-c>" , "<STR_LIT>" , <EOL> choices = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> default = "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> _run . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> choices = FORMATTERS , <EOL> default = "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = lambda formatter : FORMATTERS [ formatter ] , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> _run . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> _run . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> _run . add_argument ( "<STR_LIT>" , nargs = "<STR_LIT:+>" ) <EOL> _run . set_defaults ( func = run ) <EOL> _transform = _subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> ) <EOL> _transform . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> _transform . add_argument ( <EOL> "<STR_LIT:args>" , <EOL> nargs = argparse . REMAINDER , <EOL> ) <EOL> _transform . set_defaults ( func = transform ) </s>
