Author: tack
Date: Sun Jan 14 18:03:27 2007
New Revision: 2393
Modified:
trunk/base/src/config.py
Log:
Call expanduser on load/save filename. Add 'create' kwarg to load for
creating config files if they don't exist.
Modified: trunk/base/src/config.py
==============================================================================
--- trunk/base/src/config.py (original)
+++ trunk/base/src/config.py Sun Jan 14 18:03:27 2007
@@ -550,6 +550,7 @@
raise ValueError, "Filename not specified and no default
filename set."
filename = self._filename
+ filename = os.path.expanduser(filename)
if os.path.dirname(filename) and not
os.path.isdir(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
@@ -581,11 +582,14 @@
f.close()
- def load(self, filename = None, remember = True):
+ def load(self, filename = None, remember = True, create = False):
"""
- Load config from a config file.
+ Load config from a config file. If create kwarg is True, the config
+ file will be written immediately if it doesn't exist. Useful for
+ initializing new config files.
"""
local_encoding = get_encoding()
+ filename = os.path.expanduser(filename)
if not filename:
if not self._filename:
raise ValueError, "Filename not specified and no default
filename set."
@@ -597,6 +601,8 @@
if not os.path.isfile(filename):
# filename not found
+ if create:
+ self.save(filename)
return False
# Disable autosaving while we load the config file.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog