<s> '''<STR_LIT>''' <EOL> import os <EOL> from cola . commands import Command <EOL> from cola . context import Context <EOL> from cola . core . logs import get_logger <EOL> class StartProjectCommand ( Command ) : <EOL> def __init__ ( self ) : <EOL> self . logger = get_logger ( '<STR_LIT>' ) <EOL> def add_arguments ( self , parser ) : <EOL> self . start_project_parser = parser . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> self . start_project_parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , nargs = <NUM_LIT:1> , <EOL> help = '<STR_LIT>' ) <EOL> self . start_project_parser . set_defaults ( func = self . run ) <EOL> def _replace_variable ( self , content , kv ) : <EOL> for k , v in kv . iteritems ( ) : <EOL> content = content . replace ( '<STR_LIT>' % k , v ) <EOL> return content <EOL> def run ( self , args ) : <EOL> ctx = Context ( is_client = True , local_mode = True ) <EOL> project_name = args . project [ <NUM_LIT:0> ] <EOL> if '<STR_LIT:U+0020>' in project_name : <EOL> self . logger . error ( '<STR_LIT>' ) <EOL> current_dir = os . getcwd ( ) <EOL> project_dir = os . path . join ( current_dir , project_name ) <EOL> if not os . path . exists ( project_dir ) : <EOL> os . makedirs ( project_dir ) <EOL> for filename , src_filename in ( ( '<STR_LIT>' % project_name , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> full_filename = os . path . join ( project_dir , filename ) <EOL> full_temp_filename = os . path . join ( ctx . get_cola_dir ( ) , '<STR_LIT>' , src_filename ) <EOL> with open ( full_temp_filename ) as temp_fp : <EOL> with open ( full_filename , '<STR_LIT:w>' ) as fp : <EOL> content = self . _replace_variable ( temp_fp . read ( ) , { '<STR_LIT:name>' : project_name } ) <EOL> fp . write ( content ) <EOL> self . logger . info ( '<STR_LIT>' % project_name ) </s>
