replaces reduce with for loop in nodb driver

This commit is contained in:
Ronald Steinke 2018-10-15 10:02:01 +02:00
parent a8987f441b
commit 61b2dad009

View File

@ -65,18 +65,18 @@ class NoDB2Session(BasicSession):
if parent.__model_name__ == "onem2m": if parent.__model_name__ == "onem2m":
if resource_type is None: if resource_type is None:
resources = self.children[parent.path].values() resources = []
resources = map(dict.values, resources) for v in self.children[parent.path].values():
resources = reduce(list.__add__, resources, []) resources += list(v.values())
elif isinstance(resource_type, (list, tuple, set)): elif isinstance(resource_type, (list, tuple, set)):
resources = [v for k, v in self.children[parent.path].items() resources = []
if k in resource_type] for k, v in self.children[parent.path].items():
resources = map(dict.values, resources) if k in resource_type:
resources = reduce(list.__add__, resources, []) resources + list(v.values())
else: else:
resources = self.children[parent.path][resource_type].values() resources = list(self.children[parent.path][resource_type].values())
else: else:
resources = self.children[parent.path][resource_type].values() resources = list(self.children[parent.path][resource_type].values())
self.logger.debug("Found children: %s", resources) self.logger.debug("Found children: %s", resources)
return resources return resources