Allow multi-line CSV parameters

Feed individual lines of input into the CSV parser, and include all lines
in the output.

https://fedorahosted.org/freeipa/ticket/2402
This commit is contained in:
Petr Viktorin 2012-03-22 04:27:48 -04:00 committed by Rob Crittenden
parent 18a6ab356a
commit 0b62700c8c

View File

@ -715,14 +715,15 @@ class Param(ReadOnly):
if self.csv: if self.csv:
if type(value) not in (tuple, list): if type(value) not in (tuple, list):
value = (value,) value = (value,)
newval = () newval = []
for v in value: for v in value:
if isinstance(v, basestring): if isinstance(v, basestring):
csvreader = self.__unicode_csv_reader([unicode(v)]) lines = unicode(v).splitlines()
newval += tuple(csvreader.next()) #pylint: disable=E1101 for row in self.__unicode_csv_reader(lines):
newval.extend(row)
else: else:
newval += (v,) newval.append(v)
return newval return tuple(newval)
else: else:
return value return value