Skip to content

Commit

Permalink
accept "true" and "True" as valid values for "hasProcessingProvider"
Browse files Browse the repository at this point in the history
plugin metadata (fix #41120)
  • Loading branch information
alexbruy authored and nyalldawson committed Feb 9, 2022
1 parent 9dfb401 commit 4adffff
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/python/qgspythonutils.h
Expand Up @@ -182,7 +182,8 @@ class PYTHON_EXPORT QgsPythonUtils
/**
* Returns TRUE if a plugin implements a Processing provider.
*
* This is determined by checking the plugin metadata for the "hasProcessingProvider=yes" line.
* This is determined by checking the plugin metadata for the "hasProcessingProvider=yes"
* or "hasProcessingProvider=true" line.
*
* \see startProcessingPlugin()
* \since QGIS 3.8
Expand Down
2 changes: 1 addition & 1 deletion src/python/qgspythonutilsimpl.cpp
Expand Up @@ -645,7 +645,7 @@ QString QgsPythonUtilsImpl::getPluginMetadata( const QString &pluginName, const

bool QgsPythonUtilsImpl::pluginHasProcessingProvider( const QString &pluginName )
{
return getPluginMetadata( pluginName, QStringLiteral( "hasProcessingProvider" ) ).compare( QLatin1String( "yes" ), Qt::CaseInsensitive ) == 0;
return getPluginMetadata( pluginName, QStringLiteral( "hasProcessingProvider" ) ).compare( QLatin1String( "yes" ), Qt::CaseInsensitive ) == 0 || getPluginMetadata( pluginName, QStringLiteral( "hasProcessingProvider" ) ).compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
}

bool QgsPythonUtilsImpl::loadPlugin( const QString &packageName )
Expand Down
3 changes: 3 additions & 0 deletions tests/src/app/testqgisapppython.cpp
Expand Up @@ -124,6 +124,9 @@ void TestQgisAppPython::pluginMetadata()
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "ProcessingPluginTest" ), QStringLiteral( "name" ) ), QStringLiteral( "processing plugin test" ) );
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "ProcessingPluginTest" ), QStringLiteral( "hasProcessingProvider" ) ), QStringLiteral( "yes" ) );
QVERIFY( mQgisApp->mPythonUtils->pluginHasProcessingProvider( QStringLiteral( "ProcessingPluginTest" ) ) );
// hasProcessingProvider also accepts true/True
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "ProcessingPluginTest2" ), QStringLiteral( "hasProcessingProvider" ) ), QStringLiteral( "True" ) );
QVERIFY( mQgisApp->mPythonUtils->pluginHasProcessingProvider( QStringLiteral( "ProcessingPluginTest2" ) ) );
}

void TestQgisAppPython::pythonPluginDependencyOrder()
Expand Down
44 changes: 44 additions & 0 deletions tests/testdata/test_plugin_path/ProcessingPluginTest2/__init__.py
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Hugo Mercier
Email : hugo dot mercier at oslandia dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Hugo Mercier'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Hugo Mercier'

import os


class Test:

def __init__(self, iface):
pass

def initGui(self):
assert False

def initProcessing(self):
pass

def unload(self):
pass


def classFactory(iface):
# load Test class from file Test
return Test(iface)
@@ -0,0 +1,7 @@
[general]
name=processing plugin test 2
qgisMinimumVersion=3.8
description=desc
version=0.1
author=matt cauthin
hasProcessingProvider=True

0 comments on commit 4adffff

Please sign in to comment.