mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipachangeconf: allow specifying non-default delimeter for options
https://fedorahosted.org/freeipa/ticket/3132
This commit is contained in:
parent
0292ebd1e5
commit
daa22d4355
@ -174,9 +174,12 @@ class IPAChangeConf:
|
|||||||
self.subsectdel[1]))
|
self.subsectdel[1]))
|
||||||
continue
|
continue
|
||||||
if o['type'] == "option":
|
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],
|
output.append(self._dump_line(self.indent[level],
|
||||||
o['name'],
|
o['name'],
|
||||||
self.dassign,
|
delim,
|
||||||
o['value']))
|
o['value']))
|
||||||
continue
|
continue
|
||||||
if o['type'] == "comment":
|
if o['type'] == "comment":
|
||||||
@ -200,13 +203,21 @@ class IPAChangeConf:
|
|||||||
'type': 'comment',
|
'type': 'comment',
|
||||||
'value': value.rstrip()} # pylint: disable=E1103
|
'value': value.rstrip()} # pylint: disable=E1103
|
||||||
|
|
||||||
|
o = dict()
|
||||||
parts = line.split(self.dassign, 1)
|
parts = line.split(self.dassign, 1)
|
||||||
if len(parts) < 2:
|
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
|
||||||
|
|
||||||
return {'name': parts[0].strip(),
|
if 'delim' not in o:
|
||||||
'type': 'option',
|
raise SyntaxError, 'Syntax Error: Unknown line format'
|
||||||
'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):
|
def findOpts(self, opts, type, name, exclude_sections=False):
|
||||||
|
|
||||||
@ -256,13 +267,13 @@ class IPAChangeConf:
|
|||||||
'value': val})
|
'value': val})
|
||||||
continue
|
continue
|
||||||
if o['type'] == 'option':
|
if o['type'] == 'option':
|
||||||
val = self._dump_line(self.indent[level],
|
delim = o.get('delim', self.dassign)
|
||||||
o['name'],
|
if delim not in self.assign:
|
||||||
self.dassign,
|
val = self._dump_line(self.indent[level],
|
||||||
o['value'])
|
o['name'],
|
||||||
opts.append({'name': 'comment',
|
delim,
|
||||||
'type': 'comment',
|
o['value'])
|
||||||
'value': val})
|
opts.append({'name':'comment', 'type':'comment', 'value':val})
|
||||||
continue
|
continue
|
||||||
if o['type'] == 'comment':
|
if o['type'] == 'comment':
|
||||||
opts.append(o)
|
opts.append(o)
|
||||||
|
Loading…
Reference in New Issue
Block a user