From b9067d9400b36df649c3ea59574dc6dfc7f49802 Mon Sep 17 00:00:00 2001 From: rldhont Date: Mon, 10 May 2021 09:35:08 +0200 Subject: [PATCH] [Processing] Fix specific exception type in getParameterFromString --- python/plugins/processing/core/parameters.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/plugins/processing/core/parameters.py b/python/plugins/processing/core/parameters.py index fd835ab1051c..4197ead375dd 100755 --- a/python/plugins/processing/core/parameters.py +++ b/python/plugins/processing/core/parameters.py @@ -116,7 +116,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = [int(p) for p in params[2].split(';')] - except: + except ValueError: params[2] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[2].split(';')] if len(params) > 4: params[4] = True if params[4].lower() == 'true' else False @@ -125,7 +125,7 @@ def getParameterFromString(s, context=''): params[3] = True if params[3].lower() == 'true' else False try: params[4] = [int(p) for p in params[4].split(';')] - except: + except ValueError: params[4] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[4].split(';')] elif clazz == QgsProcessingParameterBoolean: if len(params) > 2: @@ -141,7 +141,7 @@ def getParameterFromString(s, context=''): if len(params) > 4: try: params[4] = [int(p) for p in params[4].split(';')] - except: + except ValueError: params[4] = [getattr(QgsWkbTypes, p.split(".")[1]) for p in params[4].split(';')] if len(params) > 5: params[5] = True if params[5].lower() == 'true' else False @@ -152,7 +152,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = int(params[2]) - except: + except ValueError: params[2] = getattr(QgsProcessingParameterNumber, params[2].split(".")[1]) if len(params) > 4: params[4] = True if params[4].lower() == 'true' else False @@ -179,7 +179,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = [int(p) for p in params[2].split(';')] - except: + except ValueError: params[2] = [getattr(QgsProcessing, p.split(".")[1]) for p in params[2].split(';')] if len(params) > 4: params[4] = True if params[4].lower() == 'true' else False @@ -187,7 +187,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = int(params[2]) - except: + except ValueError: params[2] = getattr(QgsProcessing, params[2].split(".")[1]) if len(params) > 4: params[4] = True if params[4].lower() == 'true' else False @@ -204,7 +204,7 @@ def getParameterFromString(s, context=''): if len(params) > 4: try: params[4] = int(params[4]) - except: + except ValueError: params[4] = getattr(QgsProcessingParameterField, params[4].split(".")[1]) if len(params) > 5: params[5] = True if params[5].lower() == 'true' else False @@ -216,7 +216,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = int(params[2]) - except: + except ValueError: params[2] = getattr(QgsProcessingParameterFile, params[2].split(".")[1]) if len(params) > 5: params[5] = True if params[5].lower() == 'true' else False @@ -224,7 +224,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = int(params[2]) - except: + except ValueError: params[2] = getattr(QgsProcessingParameterNumber, params[2].split(".")[1]) if len(params) > 3: params[3] = float(params[3].strip()) if params[3] is not None else None @@ -263,7 +263,7 @@ def getParameterFromString(s, context=''): if len(params) > 2: try: params[2] = int(params[2]) - except: + except ValueError: params[2] = getattr(QgsProcessing, params[2].split(".")[1]) if len(params) > 4: params[4] = True if params[4].lower() == 'true' else False