From 61b2dad0096a664e5704b795942257942c86078e Mon Sep 17 00:00:00 2001 From: Ronald Steinke Date: Mon, 15 Oct 2018 10:02:01 +0200 Subject: [PATCH] replaces reduce with for loop in nodb driver --- .../src/openmtc_server/db/nodb2.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/openmtc-server/src/openmtc_server/db/nodb2.py b/server/openmtc-server/src/openmtc_server/db/nodb2.py index 5d61816..b1eecdf 100644 --- a/server/openmtc-server/src/openmtc_server/db/nodb2.py +++ b/server/openmtc-server/src/openmtc_server/db/nodb2.py @@ -65,18 +65,18 @@ class NoDB2Session(BasicSession): if parent.__model_name__ == "onem2m": if resource_type is None: - resources = self.children[parent.path].values() - resources = map(dict.values, resources) - resources = reduce(list.__add__, resources, []) + resources = [] + for v in self.children[parent.path].values(): + resources += list(v.values()) elif isinstance(resource_type, (list, tuple, set)): - resources = [v for k, v in self.children[parent.path].items() - if k in resource_type] - resources = map(dict.values, resources) - resources = reduce(list.__add__, resources, []) + resources = [] + for k, v in self.children[parent.path].items(): + if k in resource_type: + resources + list(v.values()) else: - resources = self.children[parent.path][resource_type].values() + resources = list(self.children[parent.path][resource_type].values()) 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) return resources