#NEWLINE# def run( self ) : #NEWLINE# #INDENT# name = slugify ( self . name ) #NEWLINE# filename = '{0}.py' . format ( name ) #NEWLINE# test_filename = 'test_{0}.py' . format ( name ) #NEWLINE# if os . path . exists ( self . dojo_file ) : #NEWLINE# #INDENT# puts ( colored . red ( 'EasyDojo already exists' ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . listdir ( os . getcwd ( ) ) : #NEWLINE# #INDENT# puts ( colored . red ( "This dir isn't empty" ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# puts ( 'Initialize {name}' . format ( name = name ) ) #NEWLINE# with open ( self . dojo_file , 'w' ) as f : #NEWLINE# #INDENT# template = os . path . join ( os . path . dirname ( __file__ ) , 'sample_easydojo.yaml' ) #NEWLINE# config_template = open ( template ) . read ( ) #NEWLINE# config = { #NEWLINE# #INDENT# 'version' : __version__ , #NEWLINE# 'filename' : config , #NEWLINE# 'test_filename' : test_filename , #NEWLINE# 'test' : 'test_{0}' . format ( name ) , #NEWLINE# #UNINDENT# } #NEWLINE# f . write ( config_template . format ( ** config ) ) #NEWLINE# #UNINDENT# open ( filename , 'w' ) . close ( ) #NEWLINE# open ( test_filename , 'w' ) . close ( )