from beuuid import uuid_gen
from rcs import RCS, RCStestCase, CommandError
-client = config.get_val("arch_client")
-if client is None:
- client = "tla"
+DEFAULT_CLIENT = "tla"
+
+client = config.get_val("arch_client", default=DEFAULT_CLIENT)
def new():
return Arch()
config.write(f)
f.close()
-def get_val(name, section="DEFAULT", encoding=None):
+def get_val(name, section="DEFAULT", default=None, encoding=None):
"""
Get a value from the per-user config file
>>> get_val("junk") is None
True
"""
- if encoding == None:
- encoding = default_encoding
- config = ConfigParser.ConfigParser()
- f = codecs.open(path(), "r", encoding)
- config.readfp(f, path())
- f.close()
- try:
- return config.get(section, name)
- except ConfigParser.NoOptionError:
- return None
+ if os.path.exists(path()):
+ if encoding == None:
+ encoding = default_encoding
+ config = ConfigParser.ConfigParser()
+ f = codecs.open(path(), "r", encoding)
+ config.readfp(f, path())
+ f.close()
+ try:
+ return config.get(section, name)
+ except ConfigParser.NoOptionError:
+ return default
+ else:
+ return default
suite = doctest.DocTestSuite()