summaryrefslogtreecommitdiff
path: root/rtslib/utils.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-05-21 16:57:28 -0700
committerVictor Stinner <vstinner@redhat.com>2015-05-22 09:20:45 -0700
commited0e145ea3b71c5a78d766bc83316e9550195c37 (patch)
tree6070afff1fa9e7f701965f2f88bdb9d7b5a1d14e /rtslib/utils.py
parentc6a77cfda93e5f3f1a90a0c7cecdc725f9a8e7e5 (diff)
downloadrtslib-fb-ed0e145ea3b71c5a78d766bc83316e9550195c37.tar.gz
Port to Python 3
* Optimize _Backstore constructor to find a free index for the cache. Build a temporary set to check if an index is used or not. * Replace dict.iteritems() with six.iteritems(dict) * Replace dict.itervalues() with six.itervalues(dict) * Fix syntax of relative imports * Get range from six.moves to get xrange() on Python 2 and range() on Python 3 * Replace it.next() with next(it) * Stop using 2to3 in setup.py * Add Python 3 classifier to setup.py * Sort also imports
Diffstat (limited to 'rtslib/utils.py')
-rw-r--r--rtslib/utils.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/rtslib/utils.py b/rtslib/utils.py
index b392cd5..5531e8f 100644
--- a/rtslib/utils.py
+++ b/rtslib/utils.py
@@ -18,12 +18,13 @@ License for the specific language governing permissions and limitations
under the License.
'''
-import re
import os
-import stat
-import uuid
+import re
+import six
import socket
+import stat
import subprocess
+import uuid
from contextlib import contextmanager
class RTSLibError(Exception):
@@ -455,14 +456,14 @@ def _set_auth_attr(self, value, attribute, ignore=False):
raise
def set_attributes(obj, attr_dict, err_func):
- for name, value in attr_dict.iteritems():
+ for name, value in six.iteritems(attr_dict):
try:
obj.set_attribute(name, value)
except RTSLibError as e:
err_func(str(e))
def set_parameters(obj, param_dict, err_func):
- for name, value in param_dict.iteritems():
+ for name, value in six.iteritems(param_dict):
try:
obj.set_parameter(name, value)
except RTSLibError as e: