Merge "Python 3: use next() instead of iterator.next()"

This commit is contained in:
Jenkins 2015-06-10 09:13:55 +00:00 committed by Gerrit Code Review
commit 0fb46a0580
7 changed files with 19 additions and 11 deletions

View File

@ -557,13 +557,13 @@ class IpRouteCommand(IpDeviceCommandBase):
).split('\n')
for subnet_route_line in subnet_route_list_lines:
i = iter(subnet_route_line.split())
while(i.next() != 'dev'):
while(next(i) != 'dev'):
pass
device = i.next()
device = next(i)
try:
while(i.next() != 'src'):
while(next(i) != 'src'):
pass
src = i.next()
src = next(i)
except Exception:
src = ''
if device != interface_name:

View File

@ -28,9 +28,11 @@ class NeutronBase(models.ModelBase):
return self
def next(self):
n = self._i.next().name
n = next(self._i).name
return n, getattr(self, n)
__next__ = next
def __repr__(self):
"""sqlalchemy based automatic __repr__ method."""
items = ['%s=%r' % (col.name, getattr(self, col.name))

View File

@ -93,7 +93,7 @@ class SubnetAllocator(driver.Pool):
prefix_pool = self._get_available_prefix_list()
for prefix in prefix_pool:
if request.prefixlen >= prefix.prefixlen:
subnet = prefix.subnet(request.prefixlen).next()
subnet = next(prefix.subnet(request.prefixlen))
gateway_ip = request.gateway_ip
if not gateway_ip:
gateway_ip = subnet.network + 1

View File

@ -40,7 +40,7 @@ class TunnelTypeDriver(helpers.SegmentTypeDriver):
def __init__(self, model):
super(TunnelTypeDriver, self).__init__(model)
self.segmentation_key = iter(self.primary_keys).next()
self.segmentation_key = next(iter(self.primary_keys))
@abc.abstractmethod
def sync_allocations(self):
@ -203,7 +203,7 @@ class EndpointTunnelTypeDriver(TunnelTypeDriver):
def __init__(self, segment_model, endpoint_model):
super(EndpointTunnelTypeDriver, self).__init__(segment_model)
self.endpoint_model = endpoint_model
self.segmentation_key = iter(self.primary_keys).next()
self.segmentation_key = next(iter(self.primary_keys))
def get_endpoint_by_host(self, host):
LOG.debug("get_endpoint_by_host() called for host %s", host)

View File

@ -367,7 +367,7 @@ class ResponseBodyIterator(object):
def __iter__(self):
while True:
yield self.next()
yield next(self)
def next(self):
chunk = self.resp.read(CHUNKSIZE)
@ -375,3 +375,5 @@ class ResponseBodyIterator(object):
return chunk
else:
raise StopIteration()
__next__ = next

View File

@ -136,8 +136,8 @@ def router_append_subnet(router, count=1, ip_version=4,
interfaces = copy.deepcopy(router.get(l3_constants.INTERFACE_KEY, []))
if interface_id:
try:
interface = (i for i in interfaces
if i['id'] == interface_id).next()
interface = next(i for i in interfaces
if i['id'] == interface_id)
except StopIteration:
raise ValueError("interface_id not found")

View File

@ -113,6 +113,8 @@ commands = python -m testtools.run \
neutron.tests.unit.plugins.ml2.drivers.ext_test \
neutron.tests.unit.plugins.ml2.drivers.mech_sriov.test_mech_sriov_nic_switch \
neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent \
neutron.tests.unit.plugins.ml2.drivers.test_type_vxlan \
neutron.tests.unit.plugins.ml2.drivers.test_type_gre \
neutron.tests.unit.plugins.ml2.drivers.arista.test_mechanism_arista \
neutron.tests.unit.plugins.ml2.drivers.test_type_local \
neutron.tests.unit.plugins.ml2.drivers.mechanism_logger \
@ -151,6 +153,7 @@ commands = python -m testtools.run \
neutron.tests.unit.agent.l3.test_dvr_fip_ns \
neutron.tests.unit.agent.common.test_config \
neutron.tests.unit.agent.common.test_polling \
neutron.tests.unit.agent.linux.test_ip_lib \
neutron.tests.unit.agent.linux.test_keepalived \
neutron.tests.unit.agent.linux.test_ipset_manager \
neutron.tests.unit.agent.linux.test_ebtables_manager \
@ -176,6 +179,7 @@ commands = python -m testtools.run \
neutron.tests.unit.cmd.test_netns_cleanup \
neutron.tests.unit.ipam.drivers.neutrondb_ipam.test_db_api \
neutron.tests.unit.ipam.drivers.neutrondb_ipam.test_driver \
neutron.tests.unit.ipam.test_subnet_alloc \
neutron.tests.unit.notifiers.test_nova \
neutron.tests.unit.notifiers.test_batch_notifier