diff --git a/omc3/model/model_creators/abstract_model_creator.py b/omc3/model/model_creators/abstract_model_creator.py index 9adba419..a9988f8d 100644 --- a/omc3/model/model_creators/abstract_model_creator.py +++ b/omc3/model/model_creators/abstract_model_creator.py @@ -24,13 +24,15 @@ def check_folder_choices(parent: Path, msg: str, A helper function that scans a selected folder for children, which will then be displayed as possible choices """ choices = [d.name for d in parent.iterdir() if predicate(d)] - if selection is None or selection not in choices: - if list_choices: - for choice in choices: - print(choice) - return None - raise AttributeError(f"{msg}.\nSelected: '{selection}'.\nChoices: [{', '.join(choices)}]") - return parent / selection + + if selection is not None and selection in choices: + return parent / selection + + if list_choices: + for choice in choices: + print(choice) + return None + raise AttributeError(f"{msg}.\nSelected: '{selection}'.\nChoices: [{', '.join(choices)}]") class ModelCreator(ABC):