Use six.moves.map/filter/zip

partial blueprint heat-python34-support

Change-Id: Iec4d228933d5cdc2474a8090cc524673d0ecdb2c
This commit is contained in:
Sirushti Murugesan 2015-04-23 02:27:18 +05:30
parent 8d3f96929a
commit 8257306624
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,8 +222,8 @@ 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,
self._graph[key].required_by())
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,15 +51,15 @@ class PluginManager(object):
'heat.engine')
def modules():
pkg_modules = itertools.imap(plugin_loader.load_modules,
packages())
pkg_modules = six.moves.map(plugin_loader.load_modules,
packages())
return itertools.chain.from_iterable(pkg_modules)
self.modules = list(modules())
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,9 +165,9 @@ class ResourceDefinitionCore(object):
return stack[res_name]
def strict_func_deps(data, datapath):
return itertools.ifilter(lambda r: getattr(r, 'strict_dependency',
True),
function.dependencies(data, datapath))
return six.moves.filter(lambda r: getattr(r, 'strict_dependency',
True),
function.dependencies(data, datapath))
return itertools.chain((get_resource(dep) for dep in self._depends),
strict_func_deps(self._properties,

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),
arglist)
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))