diff --git a/pyotb/__init__.py b/pyotb/__init__.py index 9e49b6d8443ee854b7553e20c09819c296ed8b30..673fd2e9aab2f596d71050d84efcb77f9304668b 100644 --- a/pyotb/__init__.py +++ b/pyotb/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """This module provides convenient python wrapping of otbApplications.""" -__version__ = "2.0.1" +__version__ = "2.0.2" from .install import install_otb from .helpers import logger, set_logger_level diff --git a/pyotb/core.py b/pyotb/core.py index 0b0124910224864e8d06d2b100cf3722fc55470f..b78efd478d6c42533f78996ebfba0e70ff449fea 100644 --- a/pyotb/core.py +++ b/pyotb/core.py @@ -665,9 +665,8 @@ class App(OTBObject): def get_first_key(self, param_types: list[int]) -> str: """Get the first param key for specific file types, try each list in args.""" for param_type in param_types: - # Return the first key, from the alphabetically sorted keys of the - # application, which has the parameter type matching param_type. - for key, value in sorted(self._all_param_types.items()): + # Return the first key where type matches param_type. + for key, value in self._all_param_types.items(): if value == param_type: return key raise TypeError( @@ -1019,9 +1018,15 @@ class App(OTBObject): self.app.ConnectImage(key, obj.app, obj.output_image_key) elif isinstance(obj, otb.Application): self.app.ConnectImage(key, obj, get_out_images_param_keys(obj)[0]) + # SetParameterValue in OTB<7.4 doesn't work for ram parameter (see OTB issue 2200) elif key == "ram": - # SetParameterValue in OTB<7.4 doesn't work for ram parameter cf OTB issue 2200 self.app.SetParameterInt("ram", int(obj)) + # SetParameterValue doesn't work with ParameterType_Field (see pyotb GitHub issue #1) + elif self.app.GetParameterType(key) == otb.ParameterType_Field: + if isinstance(obj, (list, tuple)): + self.app.SetParameterStringList(key, obj) + else: + self.app.SetParameterString(key, obj) # Any other parameters (str, int...) elif not isinstance(obj, (list, tuple)): self.app.SetParameterValue(key, obj)