Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Processing] Fix specific exception type in getParameterFromString
  • Loading branch information
rldhont authored and nyalldawson committed May 20, 2021
1 parent ef05b76 commit b9067d9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions python/plugins/processing/core/parameters.py
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -179,15 +179,15 @@ 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
elif clazz == QgsProcessingParameterMultipleLayers:
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
Expand All @@ -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
Expand All @@ -216,15 +216,15 @@ 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
elif clazz == QgsProcessingParameterNumber:
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b9067d9

Please sign in to comment.