mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-01-14 08:49:56 +00:00
replaces reduce with for loop in nodb driver
This commit is contained in:
parent
a8987f441b
commit
61b2dad009
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user