<s> import os . path <EOL> from config import UserConfig <EOL> config = UserConfig ( ) <EOL> BASEDIR = config . BASEDIR <EOL> WHITE_SPACE = config . WHITE_SPACE <EOL> def generate_controller ( model_name , model_components ) : <EOL> model_name = model_name . lower ( ) <EOL> db_model_name = model_name . title ( ) <EOL> controller_path = os . path . join ( BASEDIR , '<STR_LIT>' + model_name + '<STR_LIT>' ) <EOL> controller_file = open ( controller_path , '<STR_LIT:w>' ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" + db_model_name + "<STR_LIT>" ) <EOL> controller_file . write ( model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT:@>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT:@>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + db_model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name . title ( ) + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT:=>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name . title ( ) + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name . title ( ) + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" + model_name . title ( ) + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + WHITE_SPACE + WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . close ( ) <EOL> main_path = os . path . join ( BASEDIR , '<STR_LIT>' ) <EOL> read_main_file = open ( main_path , '<STR_LIT:r>' ) <EOL> original_lines = read_main_file . readlines ( ) <EOL> original_lines [ <NUM_LIT:16> ] = original_lines [ <NUM_LIT:16> ] . strip ( ) <EOL> original_lines [ <NUM_LIT:16> ] = original_lines [ <NUM_LIT:16> ] + '<STR_LIT:U+002CU+0020>' + model_name + '<STR_LIT>' <EOL> main_file = open ( main_path , '<STR_LIT:w>' ) <EOL> for lines in original_lines : <EOL> main_file . write ( lines ) <EOL> main_file . close ( ) <EOL> main_file = open ( main_path , '<STR_LIT:a>' ) <EOL> main_file . write ( "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> main_file . close ( ) <EOL> init_path = os . path . join ( BASEDIR , '<STR_LIT>' ) <EOL> init_file = open ( init_path , '<STR_LIT:a>' ) <EOL> init_file . write ( "<STR_LIT>" + model_name + "<STR_LIT>" + model_name + "<STR_LIT>" ) <EOL> init_file . close ( ) <EOL> print "<STR_LIT>" <EOL> def add_controller ( controller_name ) : <EOL> controller_name = controller_name . lower ( ) <EOL> controller_name = controller_name . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) <EOL> controller_name = controller_name . replace ( '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> controller_name = controller_name . replace ( '<STR_LIT:.>' , '<STR_LIT:_>' ) <EOL> controller_name = controller_name . replace ( '<STR_LIT:U+002C>' , '<STR_LIT:_>' ) <EOL> controller_path = os . path . join ( BASEDIR , "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> controller_file = open ( controller_path , '<STR_LIT:w>' ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" ) <EOL> controller_file . write ( controller_name + "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT:@>" + controller_name + "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> controller_file . write ( "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . write ( WHITE_SPACE + "<STR_LIT>" ) <EOL> controller_file . close ( ) <EOL> main_path = os . path . join ( BASEDIR , '<STR_LIT>' ) <EOL> read_main_file = open ( main_path , '<STR_LIT:r>' ) <EOL> original_lines = read_main_file . readlines ( ) <EOL> original_lines [ <NUM_LIT:16> ] = original_lines [ <NUM_LIT:2> ] . strip ( ) <EOL> original_lines [ <NUM_LIT:16> ] = original_lines [ <NUM_LIT:2> ] + '<STR_LIT:U+002CU+0020>' + controller_name + '<STR_LIT>' <EOL> main_path = os . path . join ( BASEDIR , '<STR_LIT>' ) <EOL> main_file = open ( main_path , '<STR_LIT:w>' ) <EOL> for lines in original_lines : <EOL> main_file . write ( lines ) <EOL> main_file . close ( ) <EOL> main_file = open ( main_path , '<STR_LIT:a>' ) <EOL> main_file . write ( "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> main_file . close ( ) <EOL> init_path = os . path . join ( BASEDIR , '<STR_LIT>' ) <EOL> init_file = open ( init_path , '<STR_LIT:a>' ) <EOL> init_file . write ( "<STR_LIT>" + controller_name + "<STR_LIT>" + controller_name + "<STR_LIT>" ) <EOL> init_file . close ( ) <EOL> print '<STR_LIT>' </s>
