Merge "Replace itertools.ifilter with six.moves.filter"

This commit is contained in:
Jenkins
2015-10-13 10:53:45 +00:00
committed by Gerrit Code Review
5 changed files with 13 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ from __future__ import print_function
import logging
from errno import EEXIST
from itertools import islice, izip
from itertools import islice
from operator import itemgetter
from os import mkdir
from os.path import basename, abspath, dirname, exists, join as pathjoin
@@ -27,6 +27,8 @@ from textwrap import wrap
from time import time
import optparse
import math
from six.moves import zip as izip
from six.moves import input
from swift.common import exceptions

View File

@@ -27,6 +27,7 @@ import warnings
from array import array
from collections import defaultdict
import six
from six.moves import range
from time import time
@@ -501,7 +502,7 @@ class RingBuilder(object):
dispersion_graph = {}
# go over all the devices holding each replica part by part
for part_id, dev_ids in enumerate(
itertools.izip(*self._replica2part2dev)):
six.moves.zip(*self._replica2part2dev)):
# count the number of replicas of this part for each tier of each
# device, some devices may have overlapping tiers!
replicas_at_tier = defaultdict(int)

View File

@@ -19,6 +19,7 @@ import random
import time
import itertools
from collections import defaultdict
import six
import six.moves.cPickle as pickle
import shutil
@@ -799,7 +800,7 @@ class ObjectReconstructor(Daemon):
self._diskfile_mgr = self._df_router[policy]
self.load_object_ring(policy)
data_dir = get_data_dir(policy)
local_devices = list(itertools.ifilter(
local_devices = list(six.moves.filter(
lambda dev: dev and is_local_device(
ips, self.port,
dev['replication_ip'], dev['replication_port']),

View File

@@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from six.moves import urllib
from itertools import ifilter
from swift.common import bufferedhttp
from swift.common import exceptions
from swift.common import http
@@ -266,7 +266,7 @@ class Sender(object):
self.job['policy'], self.suffixes,
frag_index=self.job.get('frag_index'))
if self.remote_check_objs is not None:
hash_gen = ifilter(
hash_gen = six.moves.filter(
lambda path_objhash_timestamps:
path_objhash_timestamps[1] in
self.remote_check_objs, hash_gen)

View File

@@ -24,6 +24,7 @@
# These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise.
import six
from six.moves.urllib.parse import unquote, quote
import collections
@@ -164,15 +165,15 @@ class BaseObjectController(Controller):
all_nodes = itertools.chain(primary_nodes,
ring.get_more_nodes(partition))
first_n_local_nodes = list(itertools.islice(
itertools.ifilter(is_local, all_nodes), num_locals))
six.moves.filter(is_local, all_nodes), num_locals))
# refresh it; it moved when we computed first_n_local_nodes
all_nodes = itertools.chain(primary_nodes,
ring.get_more_nodes(partition))
local_first_node_iter = itertools.chain(
first_n_local_nodes,
itertools.ifilter(lambda node: node not in first_n_local_nodes,
all_nodes))
six.moves.filter(lambda node: node not in first_n_local_nodes,
all_nodes))
return self.app.iter_nodes(
ring, partition, node_iter=local_first_node_iter)