diff options
author | Marko Kreen | 2012-10-16 11:04:45 +0000 |
---|---|---|
committer | Marko Kreen | 2012-10-16 11:04:45 +0000 |
commit | 5077ff9551ad578228027f47d613d79692bfdfc2 (patch) | |
tree | 14d595f76bf55d163b12142e4f3c62c8307eaecd | |
parent | 01a731c376fe0b2594c66ca94dab3d13a9602fb7 (diff) |
Allow overrided options with --set to show up in --ini output
-rwxr-xr-x | python/londiste.py | 4 | ||||
-rw-r--r-- | python/skytools/scripting.py | 30 |
2 files changed, 29 insertions, 5 deletions
diff --git a/python/londiste.py b/python/londiste.py index b6c59e15..66137afc 100755 --- a/python/londiste.py +++ b/python/londiste.py @@ -60,6 +60,8 @@ cmd_handlers = ( class Londiste(skytools.DBScript): def __init__(self, args): + self.full_args = args + skytools.DBScript.__init__(self, 'londiste3', args) if len(self.args) < 2: @@ -80,7 +82,7 @@ class Londiste(skytools.DBScript): def print_ini(self): """Let the Replicator print the default config.""" - londiste.Replicator(['--ini']) + londiste.Replicator(self.full_args) def init_optparse(self, parser=None): p = skytools.DBScript.init_optparse(self, parser) diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index 12a72da9..049da251 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -273,9 +273,6 @@ class BaseScript(object): self.log_level = skytools.skylog.TRACE elif self.options.verbose: self.log_level = logging.DEBUG - if self.options.ini: - self.print_ini() - sys.exit(0) self.cf_override = {} if self.options.set: @@ -283,6 +280,10 @@ class BaseScript(object): k, v = a.split('=', 1) self.cf_override[k.strip()] = v.strip() + if self.options.ini: + self.print_ini() + sys.exit(0) + # read config file self.reload() @@ -331,8 +332,29 @@ class BaseScript(object): if pos < 0: return doc = doc[pos+2 : ].rstrip() + doc = skytools.dedent(doc) + + # merge overrided options into output + for ln in doc.splitlines(): + vals = ln.split('=', 1) + if len(vals) != 2: + print(ln) + continue + + k = vals[0].strip() + v = vals[1].strip() + if k and k[0] == '#': + print(ln) + k = k[1:] + if k in self.cf_override: + print('%s = %s' % (k, self.cf_override[k])) + elif k in self.cf_override: + if v: + print('#' + ln) + print('%s = %s' % (k, self.cf_override[k])) + else: + print(ln) - print(skytools.dedent(doc)) print('') def load_config(self): |