summaryrefslogtreecommitdiff
path: root/heatclient/common/utils.py
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2013-09-23 17:55:55 +1200
committerSteve Baker <sbaker@redhat.com>2013-09-25 16:10:32 +1200
commit795d52c6418fa3beab2e3385da11ece8fca3db37 (patch)
tree949477860d8881e972c7a6c5f5bb6633ae33eef0 /heatclient/common/utils.py
parent978e3f45423acc86b7836a4c07a42bbf878f31d4 (diff)
downloadpython-heatclient-795d52c6418fa3beab2e3385da11ece8fca3db37.tar.gz
Allow -P to be invoked multiple times
If --parameters is specified more than once it is assumed that each one contains only one parameter key=value. This means semicolons are ignored if there is more than one -P specified. This should be fully backwared compatible, a single -P will be assumed to be semicolon delimited. Change-Id: Ic202ff3e0596b786cd5b07c53509f97a95d41585 Closes-Bug: #1224825 Closes-Bug: #1229030
Diffstat (limited to 'heatclient/common/utils.py')
-rw-r--r--heatclient/common/utils.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py
index aa8ee0b..a174fff 100644
--- a/heatclient/common/utils.py
+++ b/heatclient/common/utils.py
@@ -147,17 +147,25 @@ def exit(msg=''):
def format_parameters(params):
'''Reformat parameters into dict of format expected by the API.'''
+
+ if not params:
+ return {}
+
+ # expect multiple invocations of --parameters but fall back
+ # to ; delimited if only one --parameters is specified
+ if len(params) == 1:
+ params = params[0].split(';')
+
parameters = {}
- if params:
- for count, p in enumerate(params.split(';'), 1):
- try:
- (n, v) = p.split(('='), 1)
- except ValueError:
- msg = '%s(%s). %s.' % ('Malformed parameter', p,
- 'Use the key=value format')
- raise exc.CommandError(msg)
-
- parameters[n] = v
+ for p in params:
+ try:
+ (n, v) = p.split(('='), 1)
+ except ValueError:
+ msg = '%s(%s). %s.' % ('Malformed parameter', p,
+ 'Use the key=value format')
+ raise exc.CommandError(msg)
+
+ parameters[n] = v
return parameters