<s> """<STR_LIT>""" <EOL> import argparse <EOL> import os . path <EOL> import re <EOL> import glob2 <EOL> from . generation import ( <EOL> generate_code , <EOL> parse_feature_files , <EOL> ) <EOL> MIGRATE_REGEX = re . compile ( r"<STR_LIT>" , flags = re . MULTILINE ) <EOL> def migrate_tests ( args ) : <EOL> """<STR_LIT>""" <EOL> path = args . path <EOL> for file_path in glob2 . iglob ( os . path . join ( os . path . abspath ( path ) , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> migrate_tests_in_file ( file_path ) <EOL> def migrate_tests_in_file ( file_path ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> with open ( file_path , "<STR_LIT>" ) as fd : <EOL> content = fd . read ( ) <EOL> new_content = MIGRATE_REGEX . sub ( r"<STR_LIT>" , content ) <EOL> if new_content != content : <EOL> fd . seek ( <NUM_LIT:0> ) <EOL> fd . write ( new_content ) <EOL> print ( "<STR_LIT>" . format ( file_path ) ) <EOL> else : <EOL> print ( "<STR_LIT>" . format ( file_path ) ) <EOL> except IOError : <EOL> pass <EOL> def check_existense ( file_name ) : <EOL> """<STR_LIT>""" <EOL> if not os . path . exists ( file_name ) : <EOL> raise argparse . ArgumentTypeError ( "<STR_LIT>" . format ( file_name ) ) <EOL> return file_name <EOL> def print_generated_code ( args ) : <EOL> """<STR_LIT>""" <EOL> features , scenarios , steps = parse_feature_files ( args . files ) <EOL> code = generate_code ( features , scenarios , steps ) <EOL> print ( code ) <EOL> def main ( ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( prog = "<STR_LIT>" ) <EOL> subparsers = parser . add_subparsers ( help = "<STR_LIT>" , dest = '<STR_LIT>' ) <EOL> subparsers . required = True <EOL> parser_generate = subparsers . add_parser ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser_generate . add_argument ( <EOL> "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" , <EOL> type = check_existense , <EOL> nargs = "<STR_LIT:+>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> parser_generate . set_defaults ( func = print_generated_code ) <EOL> parser_migrate = subparsers . add_parser ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser_migrate . add_argument ( <EOL> "<STR_LIT:path>" , <EOL> metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> parser_migrate . set_defaults ( func = migrate_tests ) <EOL> args = parser . parse_args ( ) <EOL> if hasattr ( args , '<STR_LIT>' ) : <EOL> args . func ( args ) </s>
