From c575dbebf9e85c1a915eda934440cdb1f9e4b240 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 13 Aug 2024 16:10:31 +0100 Subject: [PATCH] chore(component-factory): simplify code --- neuroml/nml/generatedssupersuper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/neuroml/nml/generatedssupersuper.py b/neuroml/nml/generatedssupersuper.py index c5ad619..a455325 100644 --- a/neuroml/nml/generatedssupersuper.py +++ b/neuroml/nml/generatedssupersuper.py @@ -186,14 +186,15 @@ def component_factory(cls, component_type, validate=True, **kwargs): else: comp_type_class = getattr(module_object, component_type.__name__) + comp = comp_type_class(**kwargs) + # handle component types that support __ANY__ try: anytypevalue = kwargs["__ANY__"] - # first value, so put it in a list, otherwise each element of the - # string is taken to be a new object - comp = comp_type_class(anytypeobjs_=[anytypevalue], **kwargs) + # append value to anytypeobjs_ list + comp.anytypeobjs_.append(anytypevalue) except KeyError: - comp = comp_type_class(**kwargs) + pass # additional setups where required if comp_type_class.__name__ == "Cell":