From 5d67899c225bc1d1281e688645935e547ebcec99 Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Thu, 28 Sep 2023 12:48:08 -0700 Subject: [PATCH] tuple change --- src/hdmf/common/resources.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hdmf/common/resources.py b/src/hdmf/common/resources.py index 48ad90616..faead635f 100644 --- a/src/hdmf/common/resources.py +++ b/src/hdmf/common/resources.py @@ -9,6 +9,7 @@ from glob import glob import os import zipfile +from collections import namedtuple class KeyTable(Table): @@ -414,7 +415,9 @@ def _get_file_from_container(self, **kwargs): def __check_termset_wrapper(self, **kwargs): """ Takes a list of objects and checks the fields for TermSetWrapper. - :return: [[object1, attribute_name1, wrapper1], [object2, attribute_name2, wrapper2], ...] + + wrapped_obj = namedtuple('wrapped_obj', ['object', 'attribute', 'wrapper']) + :return: [wrapped_obj(object1, attribute_name1, wrapper1), ...] """ objects = kwargs['objects'] @@ -423,12 +426,13 @@ def __check_termset_wrapper(self, **kwargs): for obj in objects: # Get all the fields, parse out the methods and internal variables obj_fields = [a for a in dir(obj) if not a.startswith('_') and not callable(getattr(obj, a))] - for attribute in obj_fields: attr = getattr(obj, attribute) if isinstance(attr, TermSetWrapper): # Search objects that are wrapped - ret.append([obj, attribute, attr]) + wrapped_obj = namedtuple('wrapped_obj', ['object', 'attribute', 'wrapper']) + ret.append(wrapped_obj(obj, attribute, attr)) + return ret @docval({'name': 'root_container', 'type': HERDManager,