Fix next issue for Python 2/3 compatible code.
change x.next() to next(x) and add __next__() for class Story: 2003430 Task: 26519 Change-Id: I4cda6f1d679e05b7f533b94840e0eb561213aa76 Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
eb6a4cae4e
commit
f2a6d355a9
|
@ -74,9 +74,12 @@ class ModelBase(object):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
n = self._i.next()
|
n = next(self._i)
|
||||||
return n, getattr(self, n)
|
return n, getattr(self, n)
|
||||||
|
|
||||||
|
# In Python 3, __next__() has replaced next().
|
||||||
|
__next__ = next
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Make the model object behave like a dict."""
|
"""Make the model object behave like a dict."""
|
||||||
for k, v in values.items():
|
for k, v in values.items():
|
||||||
|
|
|
@ -556,7 +556,7 @@ class MulticallWaiter(object):
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self._iterator.next()
|
next(self._iterator)
|
||||||
except Exception:
|
except Exception:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
self.done()
|
self.done()
|
||||||
|
|
|
@ -616,7 +616,7 @@ class Connection(object):
|
||||||
|
|
||||||
def _declare_consumer():
|
def _declare_consumer():
|
||||||
consumer = consumer_cls(self.conf, self.channel, topic, callback,
|
consumer = consumer_cls(self.conf, self.channel, topic, callback,
|
||||||
self.consumer_num.next())
|
next(self.consumer_num))
|
||||||
self.consumers.append(consumer)
|
self.consumers.append(consumer)
|
||||||
return consumer
|
return consumer
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ class Connection(object):
|
||||||
it = self.iterconsume(limit=limit)
|
it = self.iterconsume(limit=limit)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
it.next()
|
next(it)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ class Connection(object):
|
||||||
it = self.iterconsume(limit=limit)
|
it = self.iterconsume(limit=limit)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
it.next()
|
next(it)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -558,8 +558,8 @@ def unflatten_envelope(packenv):
|
||||||
h = {}
|
h = {}
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
k = i.next()
|
k = next(i)
|
||||||
h[k] = i.next()
|
h[k] = next(i)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,7 @@ class ResponseBodyIterator(object):
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
while True:
|
while True:
|
||||||
yield self.next()
|
yield next(self)
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
chunk = self.resp.read(CHUNKSIZE)
|
chunk = self.resp.read(CHUNKSIZE)
|
||||||
|
@ -300,3 +300,6 @@ class ResponseBodyIterator(object):
|
||||||
return chunk
|
return chunk
|
||||||
else:
|
else:
|
||||||
raise StopIteration()
|
raise StopIteration()
|
||||||
|
|
||||||
|
# In Python 3, __next__() has replaced next().
|
||||||
|
__next__ = next
|
||||||
|
|
Loading…
Reference in New Issue