Bug report #10783

[Processing] ParameterString return "None" as unicode

Added by Etienne Trimaille about 10 years ago. Updated about 9 years ago.

Status:Closed
Priority:Normal
Assignee:Victor Olaya
Category:Processing/Core
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:19164

Description

Hi,
In the modeler, ParameterString return a "None" value as unicode, not as NoneType.
I guess you want to return an empty unicode, no ?

I think an "else" is missing line 51 in ParameterString.py, isn't it ?

History

#1 Updated by Victor Olaya about 10 years ago

  • Status changed from Open to Feedback

can you provide an example of a model where you have that problem? I do not understand what the issue is exactly

Thanks!

#2 Updated by Etienne Trimaille about 10 years ago

This my code :

def processAlgorithm(self, progress):
    value = self.getParameterValue(self.WHITE_LIST[layer])            
    print value
    print len(value)
    print value.__class__.__name__

self.WHITE_LIST[layer] is a ParameterString which is defined by a PARAMETER_STRING (ModelerParameterDefinitionDialog) in the modeler.
None
4
unicode

However, if I let the parameterString empty in the algorithm (I deleted the block PARAMETER_STRING in the modeler), I will get the right empty value "".

#3 Updated by Victor Olaya about 10 years ago

hmm, I do not undertand how you use the modeler and python code at the same time... Could you add the model itself and the script to the issue?

Thanks!

#4 Updated by Etienne Trimaille almost 10 years ago

This code is in my own algo in python, that's why I can test python code in the modeler.

https://github.com/3liz/QgisQuickOSMPlugin/blob/master/ProcessingQuickOSM/API/OverpassQueryGeoAlgorithm.py#L76

Today, even if I put or not a ModelerParameterDefinitionDialog, I have a "None" value as unicode.

#5 Updated by Etienne Trimaille almost 10 years ago

  • Status changed from Feedback to Closed

I updated my plugin to processing 2.5.
This bug seems to be solved, now I get :


0
unicode

#6 Updated by Giovanni Manghi about 9 years ago

  • Category changed from 94 to Processing/Core

Also available in: Atom PDF