#NEWLINE# def main( project_name , template , **kwargs ) : #NEWLINE# #INDENT# cur_dir = os . getcwd ( ) #NEWLINE# project_dir = os . path . join ( cur_dir , project_name ) #NEWLINE# if ( template is None ) : #NEWLINE# #INDENT# grab_root = os . path . dirname ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) #NEWLINE# template_path = os . path . join ( grab_root , 'util/default_project' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# template_path = template #NEWLINE# #UNINDENT# if os . path . exists ( project_dir ) : #NEWLINE# #INDENT# raise GrabError ( ( 'Directory %s already exists' % project_dir ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . debug ( ( 'Copying %s to %s' % ( template_path , project_dir ) ) ) #NEWLINE# shutil . copytree ( template_path , project_dir ) #NEWLINE# project_name_camelcase = underscore_to_camelcase ( project_name ) #NEWLINE# context = { #NEWLINE# #INDENT# 'PROJECT_NAME' : project_name , #NEWLINE# 'PROJECT_NAME_CAMELCASE' : project_name_camelcase , #NEWLINE# #UNINDENT# } #NEWLINE# for ( base , dir_names , file_names ) in os . walk ( project_dir ) : #NEWLINE# #INDENT# for file_name in file_names : #NEWLINE# #INDENT# if file_name . endswith ( '.py' ) : #NEWLINE# #INDENT# file_path = os . path . join ( base , file_name ) #NEWLINE# content = process_content ( open ( file_path ) . read ( ) , context ) #NEWLINE# new_file_path = process_file_path ( file_path , context ) #NEWLINE# with open ( new_file_path , 'w' ) as out : #NEWLINE# #INDENT# out . write ( content ) #NEWLINE# #UNINDENT# if ( file_path != new_file_path ) : #NEWLINE# #INDENT# os . unlink ( file_path ) #NEWLINE# print ( ( '%s: OK' % project_name_camelcase ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( ( '%s: OK' % file_path ) )