Touch missing userwide config file before read if it's missing.
authorW. Trevor King <wking@drexel.edu>
Sun, 21 Jun 2009 11:56:05 +0000 (07:56 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 21 Jun 2009 11:56:05 +0000 (07:56 -0400)
Another bug introduced by James Rowe's user-config patch.  Obviously
it's hard to read a file if there's no file there.  I'm not sure how
it passed the unit tests earlier.  Maybe I forgot to install the
pre-commit version before running the test suite...  Anyhow, fixed
now.

libbe/config.py

index 9b1682a993e67b7ef714a870600bdb7e2cc6a1b4..e696eeb11c706310345bb23926ba3bd5cc31aa03 100644 (file)
@@ -37,6 +37,8 @@ def set_val(name, value, section="DEFAULT", encoding=None):
     if encoding == None:
         encoding = default_encoding
     config = ConfigParser.ConfigParser()
+    if os.path.exists(path()) == False: # touch file or config 
+        open(path(), "w").close()       # read chokes on missing file
     f = codecs.open(path(), "r", encoding)
     config.readfp(f, path())
     f.close()