-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QgsProcessingParameterFile extension option #45633
Comments
In latest QGIS versions if no extension is set, a default file filter will be used. So all you need is to define correct |
Please calm down and re-read previous comment as well as API docs. There are two ways to configure file parameter now: one is by specifying extension and another one is by specifying file filter string. The latter allows to set up any file filter(s) and maintain the same behaviour as before when files without extension does not trigger "MIssing parameter value" error. it is just a matter of correct setup. |
Right, because '*' is not a correct file filter string. Correct file filter does not generate any errors and allows files without extensions. |
I summarize here findings for others in case they encounter this same problem. The function does in fact work as asserted, however in my numerous searches of the API docs I was unable to find any details on the correct format of the fileFilter parameter. The naive use of a * appears at first to work by allowing selection of files without extensions in the GUI, however the error described above is raised before processAlgorithm method is executed. If however the fileFilter glob values are provided within parentheses, (*), both the GUI and the passing of the parameters works. This inconsistency creates the appearance of a bug when combined with lack of clear details in the API docs. |
@tsw-apropos would you mind submitting a PR with appropriate revisions to the documentation? Experiences like yours are very valuable to other API users, so it'd be a shame not to use this opportunity to improve the docs! |
Yes I will do so in the next few weeks as I have time. Good suggestion. |
What is the bug or the crash?
When setting an input file with the QgsProcessingParameterFile in a plugin, for Linux if the selected file is a binary file it will not have an extension. When the plugin is executed in QGIS 3.20 on Debian 11.1, this will generate a "Wrong or missing parameter value: " error. If the executable file name altered to add an extension, such as .bin, it runs fine. This error does not occur on Debian 10.11 with QGIS 3.18 or in earlier versions of QGIS this problem does not occur.
I discovered this in using the QMarxan plugin I created, however I believe the error to be some undocumented change between 3.18 and 3.20 in the QGIS Python API.
Steps to reproduce the issue
See above
Versions
3.20
Supported QGIS version
New profile
Additional context
I see two possible options to resolve this problem:
Note: I did not try a new QGIS profile as it is not relevant in this case.
The text was updated successfully, but these errors were encountered: