Merge "Use six.moves.map/filter/zip"
This commit is contained in:
commit
3c65d8885f
|
@ -547,7 +547,7 @@ class CloudLoadBalancer(resource.Resource):
|
||||||
yield norm_node
|
yield norm_node
|
||||||
|
|
||||||
def _process_nodes(self, node_list):
|
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)
|
return itertools.chain.from_iterable(node_itr)
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
|
|
|
@ -222,8 +222,8 @@ class Dependencies(object):
|
||||||
return itertools.chain([(rqr, key)], get_edges(rqr))
|
return itertools.chain([(rqr, key)], get_edges(rqr))
|
||||||
|
|
||||||
# Get the edge list for each node that requires the current node
|
# 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())
|
self._graph[key].required_by())
|
||||||
# Combine the lists into one long list
|
# Combine the lists into one long list
|
||||||
return itertools.chain.from_iterable(edge_lists)
|
return itertools.chain.from_iterable(edge_lists)
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ class ResourceRegistry(object):
|
||||||
# handle: "OS::*" -> "Dreamhost::*"
|
# handle: "OS::*" -> "Dreamhost::*"
|
||||||
def is_a_glob(resource_type):
|
def is_a_glob(resource_type):
|
||||||
return resource_type.endswith('*')
|
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:
|
for pattern in globs:
|
||||||
if self._registry[pattern].matches(resource_type):
|
if self._registry[pattern].matches(resource_type):
|
||||||
yield self._registry[pattern]
|
yield self._registry[pattern]
|
||||||
|
|
|
@ -51,15 +51,15 @@ class PluginManager(object):
|
||||||
'heat.engine')
|
'heat.engine')
|
||||||
|
|
||||||
def modules():
|
def modules():
|
||||||
pkg_modules = itertools.imap(plugin_loader.load_modules,
|
pkg_modules = six.moves.map(plugin_loader.load_modules,
|
||||||
packages())
|
packages())
|
||||||
return itertools.chain.from_iterable(pkg_modules)
|
return itertools.chain.from_iterable(pkg_modules)
|
||||||
|
|
||||||
self.modules = list(modules())
|
self.modules = list(modules())
|
||||||
|
|
||||||
def map_to_modules(self, function):
|
def map_to_modules(self, function):
|
||||||
'''Iterate over the results of calling a function on every module.'''
|
'''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):
|
class PluginMapping(object):
|
||||||
|
|
|
@ -165,9 +165,9 @@ class ResourceDefinitionCore(object):
|
||||||
return stack[res_name]
|
return stack[res_name]
|
||||||
|
|
||||||
def strict_func_deps(data, datapath):
|
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),
|
True),
|
||||||
function.dependencies(data, datapath))
|
function.dependencies(data, datapath))
|
||||||
|
|
||||||
return itertools.chain((get_resource(dep) for dep in self._depends),
|
return itertools.chain((get_resource(dep) for dep in self._depends),
|
||||||
strict_func_deps(self._properties,
|
strict_func_deps(self._properties,
|
||||||
|
|
|
@ -429,7 +429,7 @@ class DependencyTaskGroup(object):
|
||||||
been started but have not yet completed.
|
been started but have not yet completed.
|
||||||
"""
|
"""
|
||||||
running = lambda k_r: k_r[0] in self._graph and k_r[1].started()
|
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):
|
class PollingTaskGroup(object):
|
||||||
|
@ -459,10 +459,10 @@ class PollingTaskGroup(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _kwargs(kwarg_lists):
|
def _kwargs(kwarg_lists):
|
||||||
"""Return a list containing the keyword args for each subtask."""
|
"""Return a list containing the keyword args for each subtask."""
|
||||||
keygroups = (itertools.izip(itertools.repeat(name),
|
keygroups = (six.moves.zip(itertools.repeat(name),
|
||||||
arglist)
|
arglist)
|
||||||
for name, arglist in six.iteritems(kwarg_lists))
|
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
|
@classmethod
|
||||||
def from_task_with_args(cls, task, *arg_lists, **kwarg_lists):
|
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:
|
elif arg_lists and not kwarg_lists:
|
||||||
kwargs_list = [{}] * len(args_list)
|
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)
|
tasks = (functools.partial(task, *a, **kwa) for a, kwa in task_args)
|
||||||
|
|
||||||
return cls(tasks, name=task_description(task))
|
return cls(tasks, name=task_description(task))
|
||||||
|
|
Loading…
Reference in New Issue