Bug report #5934

Regex fails to detect qgisMinimumVersion in __init__ because regex wants all returns to be quoted

Added by Tim Sutton almost 12 years ago. Updated over 11 years ago.

Status:Closed
Priority:Normal
Assignee:Alessandro Pasotti
Category:-
Pull Request or Patch supplied:No

Description

If the init file first computes the return value in a var and then returns the var, the validator.py regex at line 30 fails to return any further key value pairs. See below for an example:

Fails:

def icon():
    """Icon path for the plugin - metadata.txt it will override this""" 
    myPath = os.path.join(os.path.dirname(__file__), 'gui', 'resources',
                        'img', 'icon.png')
    return myPath

def qgisMinimumVersion():
    """Minimum version of QGIS needed to run this plugin - currently set to 1.7.""" 
    return '1.7'

This works:

def icon():
    """Icon path for the plugin - metadata.txt it will override this""" 
    return os.path.join(os.path.dirname(__file__), 'gui', 'resources',
                        'img', 'icon.png')

def qgisMinimumVersion():
    """Minimum version of QGIS needed to run this plugin - currently set to 1.7.""" 
    return '1.7'

History

#1 Updated by Alessandro Pasotti almost 12 years ago

  • Status changed from Open to Feedback

It's not a bug, it's a "feature" :)

If you have a better solution than parsing init with regexps, please give your advice.

#2 Updated by Tim Sutton almost 12 years ago

I should have addeded that for me the desired behaviour would be to continue to fetch readable metadata in the event that a particular function's return cannot be parsed.

#3 Updated by Tim Sutton almost 12 years ago

Alessandro Pasotti wrote:

It's not a bug, it's a "feature" :)

If you have a better solution than parsing init with regexps, please give your advice.

Yes I agree loading the init using python is bad - using regexps is good. I tried to manipulate the regex to account for the fact that in some cases the return data is not a quoted string and to skip it, but I couldn't find a neat way to do it yet.

#4 Updated by Alessandro Pasotti over 11 years ago

  • Status changed from Feedback to Closed

Today I uploaded the new init.py parser, it should be more robust than before but it still doesn't import python (for the well know security reasons).

Given the fact that init.py usage is deprecated I'm closing this bug with wontfix.

Also available in: Atom PDF