diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-08-17 11:19:03 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-12-06 10:53:16 -0500 |
commit | daa22d4355f0b38d369276e9e7faa7a119ac4976 (patch) | |
tree | 9aa330cc0c2875a81ef8195a586560637081a361 /ipa-client | |
parent | 0292ebd1e5603a5daabf274b40fb4e10f096ea1c (diff) | |
download | freeipa-daa22d4355f0b38d369276e9e7faa7a119ac4976.tar.gz freeipa-daa22d4355f0b38d369276e9e7faa7a119ac4976.tar.xz freeipa-daa22d4355f0b38d369276e9e7faa7a119ac4976.zip |
ipachangeconf: allow specifying non-default delimeter for options
https://fedorahosted.org/freeipa/ticket/3132
Diffstat (limited to 'ipa-client')
-rw-r--r-- | ipa-client/ipaclient/ipachangeconf.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/ipa-client/ipaclient/ipachangeconf.py b/ipa-client/ipaclient/ipachangeconf.py index 6cf47b807..bdc5579fc 100644 --- a/ipa-client/ipaclient/ipachangeconf.py +++ b/ipa-client/ipaclient/ipachangeconf.py @@ -174,9 +174,12 @@ class IPAChangeConf: self.subsectdel[1])) continue if o['type'] == "option": + delim = o.get('delim', self.dassign) + if delim not in self.assign: + raise ValueError('Unknown delim "%s" must be one of "%s"' % (delim, " ".join([d for d in self.assign]))) output.append(self._dump_line(self.indent[level], o['name'], - self.dassign, + delim, o['value'])) continue if o['type'] == "comment": @@ -200,13 +203,21 @@ class IPAChangeConf: 'type': 'comment', 'value': value.rstrip()} # pylint: disable=E1103 + o = dict() parts = line.split(self.dassign, 1) if len(parts) < 2: - raise SyntaxError('Syntax Error: Unknown line format') + # The default assign didn't match, try the non-default + for d in self.assign[1:]: + parts = line.split(d, 1) + if len(parts) >= 2: + o['delim'] = d + break + + if 'delim' not in o: + raise SyntaxError, 'Syntax Error: Unknown line format' - return {'name': parts[0].strip(), - 'type': 'option', - 'value': parts[1].rstrip()} + o.update({'name':parts[0].strip(), 'type':'option', 'value':parts[1].rstrip()}) + return o def findOpts(self, opts, type, name, exclude_sections=False): @@ -256,13 +267,13 @@ class IPAChangeConf: 'value': val}) continue if o['type'] == 'option': - val = self._dump_line(self.indent[level], - o['name'], - self.dassign, - o['value']) - opts.append({'name': 'comment', - 'type': 'comment', - 'value': val}) + delim = o.get('delim', self.dassign) + if delim not in self.assign: + val = self._dump_line(self.indent[level], + o['name'], + delim, + o['value']) + opts.append({'name':'comment', 'type':'comment', 'value':val}) continue if o['type'] == 'comment': opts.append(o) |