Commit c291f9da authored by Stavros Sachtouris's avatar Stavros Sachtouris

Avoid filling config file with default values

Fixes grnet/kamaki#85
parent b0f1168b
......@@ -136,7 +136,7 @@ DEFAULTS = {
class Config(RawConfigParser):
def __init__(self, path=None, with_defaults=True):
def __init__(self, path=None, with_defaults=False):
RawConfigParser.__init__(self, dict_type=OrderedDict)
self.path = path or os.environ.get(CONFIG_ENV, CONFIG_PATH)
......@@ -455,9 +455,9 @@ class Config(RawConfigParser):
def safe_to_print(self):
dump = u'[global]\n'
for k, v in self.items('global'):
for k, v in self.items('global', include_defaults=False):
dump += u'%s = %s\n' % (escape_ctrl_chars(k), escape_ctrl_chars(v))
for r, d in self.items(CLOUD_PREFIX):
for r, d in self.items(CLOUD_PREFIX, include_defaults=False):
dump += u'\n[%s "%s"]\n' % (CLOUD_PREFIX, escape_ctrl_chars(r))
for k, v in d.items():
dump += u'%s = %s\n' % (
......
......@@ -483,7 +483,8 @@ class Config(TestCase):
_cnf = Config(path=self.f.name)
bu_func = Config.items
try:
Config.items = lambda cls, opt: itemsd[opt].items()
Config.items = (
lambda cls, opt, include_defaults: itemsd[opt].items())
saved = _cnf.safe_to_print().split('\n')
glb, cld = saved[:5], saved[6:]
self.assertEqual(u'[global]', glb[0])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment