diff options
author | Stanislav Kudriashev <stas.kudriashev@gmail.com> | 2014-08-21 16:04:21 +0300 |
---|---|---|
committer | Stanislav Kudriashev <stas.kudriashev@gmail.com> | 2014-08-28 10:59:03 +0300 |
commit | a71611f9165bf168706707f06708acbdfa0ba250 (patch) | |
tree | 73ca9eb9fdd610631d12b0aff1cbebc4996b3ef8 | |
parent | deb850b7282995d7e3b31210c177a2661578765b (diff) | |
download | python-neutronclient-a71611f9165bf168706707f06708acbdfa0ba250.tar.gz |
Small improve of str2dict function
Change-Id: Ifa8974f2cbdac4fdc0cbd47d7ad9910a5bd31cb7
-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 b26166d..87dec4c 100644 --- a/neutronclient/common/utils.py +++ b/neutronclient/common/utils.py @@ -138,22 +138,17 @@ def get_item_properties(item, fields, mixed_case_fields=[], formatters={}): 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): |