From a46a040a30c42bbb79a166256b68fdabc8836897 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath@c-s.fr> Date: Fri, 27 Mar 2015 16:45:28 +0100 Subject: [PATCH] strict checking of case on parameter keys Signed-off-by: Rashad Kanavath <rashad.kanavath@c-s.fr> --- Modules/Wrappers/SWIG/src/otbApplication.i | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 17d52bba0c..0648e30c74 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -480,11 +480,10 @@ import keyword parameters in the 'otb application' with instance App """ if attr is not None: - - if attr.lower() in self.GetParametersKeys(True): + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if attr in key_list: attr = attr.lower() parameter_type = self.GetParameterType(attr) - if parameter_type in [ParameterType_InputProcessXML, ParameterType_Choice, ParameterType_String, ParameterType_InputFilename, ParameterType_OutputImage, ParameterType_OutputVectorData, @@ -502,10 +501,8 @@ import keyword return self.GetParameterFloat(attr) elif parameter_type in [ParameterType_Empty]: return self.IsParameterEnabled(attr) - else: - raise AttributeError else: - pass + raise AttributeError def __setattr__(self, attr, value): """ @@ -518,7 +515,8 @@ import keyword list of existing parameters for application with 'self.GetParametersKeys(True)' """ if attr is not None: - if attr.lower() in self.GetParametersKeys(True): + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if attr in key_list: attr = attr.lower() parameter_type = self.GetParameterType(attr) if parameter_type in [ParameterType_InputProcessXML, ParameterType_Choice, @@ -542,7 +540,7 @@ import keyword # # not reaching here due to swig seeing self.__dict__ as yet another object return dict.__setattr__(self, attr, value) else: - raise AttributeError + raise AttributeError } } -- GitLab