Merge "Use six.moves.map/filter/zip"

This commit is contained in:
Jenkins 2015-04-24 10:37:35 +00:00 committed by Gerrit Code Review
commit 3c65d8885f
6 changed files with 15 additions and 15 deletions

View File

@ -547,7 +547,7 @@ class CloudLoadBalancer(resource.Resource):
yield norm_node
def _process_nodes(self, node_list):
node_itr = itertools.imap(self._process_node, node_list)
node_itr = six.moves.map(self._process_node, node_list)
return itertools.chain.from_iterable(node_itr)
def handle_create(self):

View File

@ -222,7 +222,7 @@ class Dependencies(object):
return itertools.chain([(rqr, key)], get_edges(rqr))
# Get the edge list for each node that requires the current node
edge_lists = itertools.imap(requirer_edges,
edge_lists = six.moves.map(requirer_edges,
self._graph[key].required_by())
# Combine the lists into one long list
return itertools.chain.from_iterable(edge_lists)

View File

@ -348,7 +348,7 @@ class ResourceRegistry(object):
# handle: "OS::*" -> "Dreamhost::*"
def is_a_glob(resource_type):
return resource_type.endswith('*')
globs = itertools.ifilter(is_a_glob, six.iterkeys(self._registry))
globs = six.moves.filter(is_a_glob, six.iterkeys(self._registry))
for pattern in globs:
if self._registry[pattern].matches(resource_type):
yield self._registry[pattern]

View File

@ -51,7 +51,7 @@ class PluginManager(object):
'heat.engine')
def modules():
pkg_modules = itertools.imap(plugin_loader.load_modules,
pkg_modules = six.moves.map(plugin_loader.load_modules,
packages())
return itertools.chain.from_iterable(pkg_modules)
@ -59,7 +59,7 @@ class PluginManager(object):
def map_to_modules(self, function):
'''Iterate over the results of calling a function on every module.'''
return itertools.imap(function, self.modules)
return six.moves.map(function, self.modules)
class PluginMapping(object):

View File

@ -165,7 +165,7 @@ class ResourceDefinitionCore(object):
return stack[res_name]
def strict_func_deps(data, datapath):
return itertools.ifilter(lambda r: getattr(r, 'strict_dependency',
return six.moves.filter(lambda r: getattr(r, 'strict_dependency',
True),
function.dependencies(data, datapath))

View File

@ -429,7 +429,7 @@ class DependencyTaskGroup(object):
been started but have not yet completed.
"""
running = lambda k_r: k_r[0] in self._graph and k_r[1].started()
return itertools.ifilter(running, six.iteritems(self._runners))
return six.moves.filter(running, six.iteritems(self._runners))
class PollingTaskGroup(object):
@ -459,10 +459,10 @@ class PollingTaskGroup(object):
@staticmethod
def _kwargs(kwarg_lists):
"""Return a list containing the keyword args for each subtask."""
keygroups = (itertools.izip(itertools.repeat(name),
keygroups = (six.moves.zip(itertools.repeat(name),
arglist)
for name, arglist in six.iteritems(kwarg_lists))
return [dict(kwargs) for kwargs in itertools.izip(*keygroups)]
return [dict(kwargs) for kwargs in six.moves.zip(*keygroups)]
@classmethod
def from_task_with_args(cls, task, *arg_lists, **kwarg_lists):
@ -501,7 +501,7 @@ class PollingTaskGroup(object):
elif arg_lists and not kwarg_lists:
kwargs_list = [{}] * len(args_list)
task_args = itertools.izip(args_list, kwargs_list)
task_args = six.moves.zip(args_list, kwargs_list)
tasks = (functools.partial(task, *a, **kwa) for a, kwa in task_args)
return cls(tasks, name=task_description(task))