File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 2424class PostInstall (install ):
2525 def run (self ):
2626 import configobj
27- with open (home + '/.clid.ini' , 'w' ) as new : # make an ini file: ~/.clid.ini
28- old = open (here + '/clid/config.ini' , 'r' ).read ()
29- new .write (old )
3027
31- config = configobj .ConfigObj (home + '/.clid.ini' ) # set the default music dir as ~/Music
32- config ['music_dir' ] = home + '/Music/'
33- config .write ()
28+ default = configobj .ConfigObj (here + '/clid/config.ini' ) # get the ini file with default settings
29+ try :
30+ # get user's config file if app is already installed
31+ user = configobj .ConfigObj (home + '/.clid.ini' , file_error = True )
32+ except OSError :
33+ # expand `~/Music` if app is being installed for the first time
34+ user = configobj .ConfigObj (home + '/.clid.ini' )
35+ user ['music_dir' ] = home + '/Music/'
36+
37+ default .update (user ) # save user's settings and add new settings options
38+ default .write (outfile = open (home + '/.clid.ini' , 'wb' )) # will raise error if outfile is filename
3439
3540 install .run (self )
3641
You can’t perform that action at this time.
0 commit comments