From 6fbe192f2c31a76ebeef41a2e3b4b0abd694142e Mon Sep 17 00:00:00 2001 From: Rubel Date: Wed, 29 Nov 2023 18:52:42 +0100 Subject: [PATCH] moving to the old code. --- pynxtools/dataconverter/template.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pynxtools/dataconverter/template.py b/pynxtools/dataconverter/template.py index 230bc7254..a93c921e6 100644 --- a/pynxtools/dataconverter/template.py +++ b/pynxtools/dataconverter/template.py @@ -127,20 +127,24 @@ def __contains__(self, k): def get(self, key, return_value=None): """Implementing get method for template. - Parameters ---------- key : str Template key return_value : Any - return : The value comes with return_value """ - try: - return self.__getitem__(key) - except KeyError: + val = self.optional.get(key, None) + if val is None: + val = self.recommended.get(key, None) + if val is None: + val = self.required.get(key, None) + if val is None: + val = self.undocumented.get(key, None) + if val is None: return return_value + return val def __getitem__(self, k): """Handles how values are accessed from the Template object."""