summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-02-23 07:29:47 -0500
committerRob Crittenden <rcritten@redhat.com>2012-03-20 20:03:54 -0400
commitdddebe23507749486fb09d219f0da4f483ba4e79 (patch)
tree968e860043b04097a40d939f5e39c404b519a378 /ipalib/frontend.py
parent8f71f42ef7c7c67c0d0ee47814715e2c023d95ce (diff)
downloadfreeipa-dddebe23507749486fb09d219f0da4f483ba4e79.tar.gz
freeipa-dddebe23507749486fb09d219f0da4f483ba4e79.tar.xz
freeipa-dddebe23507749486fb09d219f0da4f483ba4e79.zip
Only split CSV in the client, quote instead of escaping
Splitting on commas is not an idempotent operation: 'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c') That means we can't do it when the call is forwarded, so this is only done on the CLI. The UI already sends values as a tuple. Replace escaping in the csv parser with quoting. Quoted strings can have embedded commas instead of having to escape them. This prevents the csv parser from eating all escape characters. Also, document Param's csv arguments, and update tests. https://fedorahosted.org/freeipa/ticket/2417 https://fedorahosted.org/freeipa/ticket/2227
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index da25b4c1a..47c72d1ab 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -557,6 +557,26 @@ class Command(HasParam):
if name in params:
yield(name, params[name])
+ def split_csv(self, **kw):
+ """
+ Return a dictionary of values where values are decoded from CSV.
+
+ For example:
+
+ >>> class my_command(Command):
+ ... takes_options = (
+ ... Param('flags', multivalue=True, csv=True),
+ ... )
+ ...
+ >>> c = my_command()
+ >>> c.finalize()
+ >>> c.split_csv(flags=u'public,replicated')
+ {'flags': (u'public', u'replicated')}
+ """
+ return dict(
+ (k, self.params[k].split_csv(v)) for (k, v) in kw.iteritems()
+ )
+
def normalize(self, **kw):
"""
Return a dictionary of normalized values.