Skip to content

Commit 6c82677

Browse files
committed
prefs are now saved when updating the app
1 parent 3d68a89 commit 6c82677

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.CHANGELOG.md.swp

12 KB
Binary file not shown.

setup.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@
2424
class 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

0 commit comments

Comments
 (0)