#NEWLINE# def add_config( self , config , parent = None , copy_dir = None ) : #NEWLINE# #INDENT# config_dir = os . path . join ( self . path , CONFIG_DIR , config ) #NEWLINE# if os . path . exists ( config_dir ) : #NEWLINE# #INDENT# raise errors . UserError ( ( '%s: config %r already exists' % ( self . name , config ) ) ) #NEWLINE# #UNINDENT# if copy_dir : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# shutil . copytree ( copy_dir , config_dir , symlinks = True ) #NEWLINE# #UNINDENT# except ( IOError , OSError ) as error : #NEWLINE# #INDENT# raise errors . Error ( ( 'copying config files failed: %s: %s' % ( error . __class__ . __name__ , error ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# os . makedirs ( config_dir ) #NEWLINE# #UNINDENT# conf_file = os . path . join ( config_dir , CONFIG_CONF_FILE ) #NEWLINE# conf = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if parent : #NEWLINE# #INDENT# conf [ 'parent' ] = parent #NEWLINE# #UNINDENT# util . json_dump ( conf , conf_file ) #NEWLINE# settings_dir = os . path . join ( config_dir , SETTINGS_DIR ) #NEWLINE# if ( not os . path . exists ( settings_dir ) ) : #NEWLINE# #INDENT# os . mkdir ( settings_dir )