<s> from finder import ( find_steps_modules , <EOL> find_text_specs , <EOL> find_before_all , <EOL> find_before_each , <EOL> find_after_all , <EOL> find_after_each , ) <EOL> from runner import StoryRunner <EOL> from optparse import OptionParser <EOL> import sys <EOL> import os <EOL> def pycukes_console ( stories_dir , steps_dir , output , colored = False ) : <EOL> modules = find_steps_modules ( steps_dir ) <EOL> for spec in find_text_specs ( stories_dir ) : <EOL> StoryRunner ( spec , output , colored = colored , modules = modules ) . run ( ) <EOL> def main ( ) : <EOL> steps_modules = [ ] <EOL> files = [ ] <EOL> before_all_methods = [ ] <EOL> before_each_methods = [ ] <EOL> after_all_methods = [ ] <EOL> after_each_methods = [ ] <EOL> stories_dirname = '<STR_LIT>' <EOL> for arg in sys . argv [ <NUM_LIT:1> : ] : <EOL> if arg . startswith ( '<STR_LIT:->' ) : <EOL> break <EOL> files . append ( arg ) <EOL> stories_dirname = os . path . dirname ( arg ) or '<STR_LIT:.>' <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = None , dest = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = None , dest = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = None , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , default = None , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT>' , dest = '<STR_LIT>' ) <EOL> values , args = parser . parse_args ( ) <EOL> try : <EOL> if values . stories_dir : <EOL> files . extend ( [ values . stories_dir + '<STR_LIT:/>' + filename for filename in os . listdir ( values . stories_dir ) <EOL> if filename . endswith ( '<STR_LIT>' ) ] ) <EOL> stories_dirname = values . stories_dir <EOL> elif files == [ ] : <EOL> files . extend ( [ stories_dirname + '<STR_LIT:/>' + filename for filename in os . listdir ( stories_dirname ) <EOL> if filename . endswith ( '<STR_LIT>' ) ] ) <EOL> steps_modules = find_steps_modules ( values . steps_dir or stories_dirname + '<STR_LIT>' ) <EOL> except OSError : <EOL> pass <EOL> if os . path . exists ( stories_dirname + '<STR_LIT>' ) : <EOL> before_all_methods = find_before_all ( stories_dirname + '<STR_LIT>' ) <EOL> after_all_methods = find_after_all ( stories_dirname + '<STR_LIT>' ) <EOL> before_each_methods = find_before_each ( stories_dirname + '<STR_LIT>' ) <EOL> after_each_methods = find_after_each ( stories_dirname + '<STR_LIT>' ) <EOL> colored = True <EOL> if values . no_colors and not values . colored : <EOL> colored = False <EOL> exit_code = True <EOL> for index , story in enumerate ( files ) : <EOL> story_status = StoryRunner ( open ( story ) . read ( ) , <EOL> sys . stdout , <EOL> colored = colored , <EOL> modules = steps_modules , <EOL> language = values . language , <EOL> before_all = before_all_methods , <EOL> before_each = before_each_methods , <EOL> after_all = after_all_methods , <EOL> after_each = after_each_methods ) . run ( ) <EOL> exit_code = exit_code and story_status <EOL> if index < len ( files ) - <NUM_LIT:1> : <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> exit ( int ( not exit_code ) ) </s>
