Merge "Replace itertools.ifilter with six.moves.filter"
This commit is contained in:
@@ -18,7 +18,7 @@ from __future__ import print_function
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from errno import EEXIST
|
from errno import EEXIST
|
||||||
from itertools import islice, izip
|
from itertools import islice
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from os import mkdir
|
from os import mkdir
|
||||||
from os.path import basename, abspath, dirname, exists, join as pathjoin
|
from os.path import basename, abspath, dirname, exists, join as pathjoin
|
||||||
@@ -27,6 +27,8 @@ from textwrap import wrap
|
|||||||
from time import time
|
from time import time
|
||||||
import optparse
|
import optparse
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
from six.moves import zip as izip
|
||||||
from six.moves import input
|
from six.moves import input
|
||||||
|
|
||||||
from swift.common import exceptions
|
from swift.common import exceptions
|
||||||
|
@@ -27,6 +27,7 @@ import warnings
|
|||||||
|
|
||||||
from array import array
|
from array import array
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import six
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
@@ -501,7 +502,7 @@ class RingBuilder(object):
|
|||||||
dispersion_graph = {}
|
dispersion_graph = {}
|
||||||
# go over all the devices holding each replica part by part
|
# go over all the devices holding each replica part by part
|
||||||
for part_id, dev_ids in enumerate(
|
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
|
# count the number of replicas of this part for each tier of each
|
||||||
# device, some devices may have overlapping tiers!
|
# device, some devices may have overlapping tiers!
|
||||||
replicas_at_tier = defaultdict(int)
|
replicas_at_tier = defaultdict(int)
|
||||||
|
@@ -19,6 +19,7 @@ import random
|
|||||||
import time
|
import time
|
||||||
import itertools
|
import itertools
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import six
|
||||||
import six.moves.cPickle as pickle
|
import six.moves.cPickle as pickle
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@@ -799,7 +800,7 @@ class ObjectReconstructor(Daemon):
|
|||||||
self._diskfile_mgr = self._df_router[policy]
|
self._diskfile_mgr = self._df_router[policy]
|
||||||
self.load_object_ring(policy)
|
self.load_object_ring(policy)
|
||||||
data_dir = get_data_dir(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(
|
lambda dev: dev and is_local_device(
|
||||||
ips, self.port,
|
ips, self.port,
|
||||||
dev['replication_ip'], dev['replication_port']),
|
dev['replication_ip'], dev['replication_port']),
|
||||||
|
@@ -13,9 +13,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
from itertools import ifilter
|
|
||||||
from swift.common import bufferedhttp
|
from swift.common import bufferedhttp
|
||||||
from swift.common import exceptions
|
from swift.common import exceptions
|
||||||
from swift.common import http
|
from swift.common import http
|
||||||
@@ -266,7 +266,7 @@ class Sender(object):
|
|||||||
self.job['policy'], self.suffixes,
|
self.job['policy'], self.suffixes,
|
||||||
frag_index=self.job.get('frag_index'))
|
frag_index=self.job.get('frag_index'))
|
||||||
if self.remote_check_objs is not None:
|
if self.remote_check_objs is not None:
|
||||||
hash_gen = ifilter(
|
hash_gen = six.moves.filter(
|
||||||
lambda path_objhash_timestamps:
|
lambda path_objhash_timestamps:
|
||||||
path_objhash_timestamps[1] in
|
path_objhash_timestamps[1] in
|
||||||
self.remote_check_objs, hash_gen)
|
self.remote_check_objs, hash_gen)
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
# These shenanigans are to ensure all related objects can be garbage
|
# These shenanigans are to ensure all related objects can be garbage
|
||||||
# collected. We've seen objects hang around forever otherwise.
|
# collected. We've seen objects hang around forever otherwise.
|
||||||
|
|
||||||
|
import six
|
||||||
from six.moves.urllib.parse import unquote, quote
|
from six.moves.urllib.parse import unquote, quote
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
@@ -164,14 +165,14 @@ class BaseObjectController(Controller):
|
|||||||
all_nodes = itertools.chain(primary_nodes,
|
all_nodes = itertools.chain(primary_nodes,
|
||||||
ring.get_more_nodes(partition))
|
ring.get_more_nodes(partition))
|
||||||
first_n_local_nodes = list(itertools.islice(
|
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
|
# refresh it; it moved when we computed first_n_local_nodes
|
||||||
all_nodes = itertools.chain(primary_nodes,
|
all_nodes = itertools.chain(primary_nodes,
|
||||||
ring.get_more_nodes(partition))
|
ring.get_more_nodes(partition))
|
||||||
local_first_node_iter = itertools.chain(
|
local_first_node_iter = itertools.chain(
|
||||||
first_n_local_nodes,
|
first_n_local_nodes,
|
||||||
itertools.ifilter(lambda node: node not in first_n_local_nodes,
|
six.moves.filter(lambda node: node not in first_n_local_nodes,
|
||||||
all_nodes))
|
all_nodes))
|
||||||
|
|
||||||
return self.app.iter_nodes(
|
return self.app.iter_nodes(
|
||||||
|
Reference in New Issue
Block a user