#NEWLINE# def configure( args ) : #NEWLINE# #INDENT# if args . switch : #NEWLINE# #INDENT# change_default_profile ( args . switch ) #NEWLINE# return #NEWLINE# #UNINDENT# config = ConfigParser ( ) #NEWLINE# config . add_section ( 'profiles' ) #NEWLINE# config [ 'profiles' ] [ 'host[1]' ] = ( input ( '>> MPD host [localhost]: ' ) or 'localhost' ) #NEWLINE# config [ 'profiles' ] [ 'port[1]' ] = ( input ( '>> MPD port [6600]: ' ) or '6600' ) #NEWLINE# config [ 'profiles' ] [ 'password[1]' ] = ( input ( '>> MPD password []: ' ) or '' ) #NEWLINE# print ( '\n' ) #NEWLINE# config . add_section ( 'mpdc' ) #NEWLINE# print ( 'Later, you will propably need to store and edit your collections/playlists in a specific file. Please create an empty file (e.g. collections.mpdc) where you want and write its path below.' ) #NEWLINE# while True : #NEWLINE# #INDENT# path = input ( '>> Full path of the collections file: ' ) #NEWLINE# if os . path . isfile ( path ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# warning ( ( 'Cannot find the file: ' + path ) ) #NEWLINE# #UNINDENT# print ( '\n' ) #NEWLINE# config [ 'mpdc' ] [ 'collections' ] = path #NEWLINE# colors = ( input ( '>> Enable colors [Y/n]: ' ) . lower ( ) or 'y' ) #NEWLINE# if ( colors == 'y' ) : #NEWLINE# #INDENT# config [ 'mpdc' ] [ 'colors' ] = 'green, red, blue' #NEWLINE# #UNINDENT# print ( '\n' ) #NEWLINE# config [ 'mpdc' ] [ 'columns' ] = 'artist, title, album' #NEWLINE# filepath = os . path . expanduser ( '~/.mpdc' ) #NEWLINE# try : #NEWLINE# #INDENT# with open ( args , 'w' ) as configfile : #NEWLINE# #INDENT# config . write ( configfile ) #NEWLINE# info ( ( 'Writing configuration file in: ' + filepath ) ) #NEWLINE# #UNINDENT# #UNINDENT# except IOError : #NEWLINE# #INDENT# warning ( ( 'Cannot write configuration file in: ' + filepath ) )