diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-09-09 03:09:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-09-09 03:09:59 +0000 |
| commit | 46630bad74174adfcf1cfff9b60be89b168cc406 (patch) | |
| tree | 456fce2b6a6603c3fb58573c2b86e09ebdb7489a | |
| parent | 4bc37901af8b8863ffaccf977e03238d73245919 (diff) | |
| parent | a71611f9165bf168706707f06708acbdfa0ba250 (diff) | |
| download | python-neutronclient-46630bad74174adfcf1cfff9b60be89b168cc406.tar.gz | |
Merge "Small improve of str2dict function"
| -rw-r--r-- | neutronclient/common/utils.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/neutronclient/common/utils.py b/neutronclient/common/utils.py index af0ddb9..a54b39c 100644 --- a/neutronclient/common/utils.py +++ b/neutronclient/common/utils.py @@ -104,22 +104,17 @@ def get_item_properties(item, fields, mixed_case_fields=(), formatters=None): def str2bool(strbool): if strbool is None: return None - else: - return strbool.lower() == 'true' + return strbool.lower() == 'true' def str2dict(strdict): - '''Convert key1=value1,key2=value2,... string into dictionary. - - :param strdict: key1=value1,key2=value2 - ''' - _info = {} - if not strdict: - return _info - for kv_str in strdict.split(","): - k, v = kv_str.split("=", 1) - _info.update({k: v}) - return _info + """Convert key1=value1,key2=value2,... string into dictionary. + + :param strdict: key1=value1,key2=value2 + """ + if not strdict: + return {} + return dict([kv.split('=', 1) for kv in strdict.split(',')]) def http_log_req(_logger, args, kwargs): |
