summaryrefslogtreecommitdiff
path: root/cinderclient/shell.py
diff options
context:
space:
mode:
authorxianming mao <xianming.mao@easystack.cn>2016-12-21 13:58:23 +0800
committerxianming.mao <xianming.mao@easystack.cn>2017-01-10 08:55:30 +0000
commit44507540f6904e2ae5bba8283723de2f6748810b (patch)
tree0baafb5f90a1df03b1fc26bc7b9200d58f36e7ca /cinderclient/shell.py
parent4eb63b8ef278de2e82e3b4957b95ba6fd9032e4f (diff)
downloadpython-cinderclient-44507540f6904e2ae5bba8283723de2f6748810b.tar.gz
Python3 common patterns
Modify some codes in order to lead them meet the python3 common pattern. Look through the following patterns of Cinder, map() and filter() if a list is needed on Python 3: Replace map(func, data) with [func(item) for item in data] Replace filter(lambda obj: test(obj), data) with [obj for obj in data if test(obj)] Replace exceptions.OSError with OSError and remove "import exceptions" Replace iterator.next() with next(iterator) Replace basestring with six.string_types Replace unicode with six.text_type Replace (str, unicode) with six.string_types Replace "for key in dict.iterkeys()" with "for key in dict" Replace dict.iteritems() with dict.items() Replace dict.itervalues() with dict.values() I found that only "filter(lambda obj: test(obj), data)" and "map(func, data)"need to modify. The other items are not be founded in Cinder. Reference:https://wiki.openstack.org/wiki/Python3#Common_patterns Change-Id: If33ec39eb176c14086132d3099c6ec577f956ded
Diffstat (limited to 'cinderclient/shell.py')
-rw-r--r--cinderclient/shell.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/cinderclient/shell.py b/cinderclient/shell.py
index 5f56a4c..4ba2f81 100644
--- a/cinderclient/shell.py
+++ b/cinderclient/shell.py
@@ -952,8 +952,8 @@ def main():
if sys.version_info >= (3, 0):
OpenStackCinderShell().main(sys.argv[1:])
else:
- OpenStackCinderShell().main(map(encodeutils.safe_decode,
- sys.argv[1:]))
+ OpenStackCinderShell().main([encodeutils.safe_decode(item)
+ for item in sys.argv[1:]])
except KeyboardInterrupt:
print("... terminating cinder client", file=sys.stderr)
sys.exit(130)