mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
[Plugin Manager] Maximum major, minor and bugfix version is 99.99.99. Be consistent with this constraint.
This commit is contained in:
parent
3361d85297
commit
f54d979106
@ -618,7 +618,7 @@ class Plugins(QObject):
|
|||||||
qgisMinimumVersion = pluginMetadata("qgisMinimumVersion").strip()
|
qgisMinimumVersion = pluginMetadata("qgisMinimumVersion").strip()
|
||||||
if not qgisMinimumVersion: qgisMinimumVersion = "0"
|
if not qgisMinimumVersion: qgisMinimumVersion = "0"
|
||||||
qgisMaximumVersion = pluginMetadata("qgisMaximumVersion").strip()
|
qgisMaximumVersion = pluginMetadata("qgisMaximumVersion").strip()
|
||||||
if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".999"
|
if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
|
||||||
#if compatible, add the plugin to the list
|
#if compatible, add the plugin to the list
|
||||||
if not isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
|
if not isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
|
||||||
error = "incompatible"
|
error = "incompatible"
|
||||||
|
@ -121,21 +121,9 @@ def compareVersions(a,b):
|
|||||||
b = normalizeVersion(b)
|
b = normalizeVersion(b)
|
||||||
if a == b:
|
if a == b:
|
||||||
return 0
|
return 0
|
||||||
# convert the strings to the lists
|
# convert the strings to lists
|
||||||
v1 = chopString(a)
|
v1 = chopString(a)
|
||||||
v2 = chopString(b)
|
v2 = chopString(b)
|
||||||
|
|
||||||
# !! ensure the version contains at least 3 segments. Fill to "x.y.z with "999" segments if needed.
|
|
||||||
# 999 must me unicode because of isnumeric method used.
|
|
||||||
if len(v1) == 2:
|
|
||||||
v1 += [u"999"]
|
|
||||||
elif len(v1) == 1:
|
|
||||||
v1 += [u"999",u"999"]
|
|
||||||
if len(v2) == 2:
|
|
||||||
v2 += [u"999"]
|
|
||||||
elif len(v2) == 1:
|
|
||||||
v2 += [u"999",u"999"]
|
|
||||||
|
|
||||||
# set the shorter string as a base
|
# set the shorter string as a base
|
||||||
l = len(v1)
|
l = len(v1)
|
||||||
if l > len(v2):
|
if l > len(v2):
|
||||||
@ -159,9 +147,10 @@ def compareVersions(a,b):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
COMPARE CURRENT QGIS VERSION WITH qgisMinimumVersion AND qgisMaximumVersion
|
||||||
## COMPARE CURRENT QGIS VERSION WITH qgisMinimumVersion AND qgisMaximumVersion """
|
ALLOWED FORMATS ARE: major.minor OR major.minor.bugfix, where each segment must be 0..99
|
||||||
|
"""
|
||||||
|
|
||||||
def splitVersion(s):
|
def splitVersion(s):
|
||||||
""" split string into 2 or 3 numerical segments """
|
""" split string into 2 or 3 numerical segments """
|
||||||
@ -171,7 +160,7 @@ def splitVersion(s):
|
|||||||
for c in l:
|
for c in l:
|
||||||
if not c.isnumeric():
|
if not c.isnumeric():
|
||||||
return None
|
return None
|
||||||
if int(c)>999:
|
if int(c)>99:
|
||||||
return None
|
return None
|
||||||
if len(l) not in [2,3]:
|
if len(l) not in [2,3]:
|
||||||
return None
|
return None
|
||||||
@ -188,7 +177,7 @@ def isCompatible(curVer, minVer, maxVer=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if not maxVer:
|
if not maxVer:
|
||||||
maxVer = [minVer[0], "999", "999"]
|
maxVer = [minVer[0], "99", "99"]
|
||||||
|
|
||||||
if len(minVer)<3:
|
if len(minVer)<3:
|
||||||
minVer += ["0"]
|
minVer += ["0"]
|
||||||
@ -197,10 +186,10 @@ def isCompatible(curVer, minVer, maxVer=None):
|
|||||||
curVer += ["0"]
|
curVer += ["0"]
|
||||||
|
|
||||||
if len(maxVer)<3:
|
if len(maxVer)<3:
|
||||||
maxVer += ["999"]
|
maxVer += ["99"]
|
||||||
|
|
||||||
minVer = "%03d%03d%03d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) )
|
minVer = "%02d%02d%02d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) )
|
||||||
maxVer = "%03d%03d%03d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) )
|
maxVer = "%02d%02d%02d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) )
|
||||||
curVer = "%03d%03d%03d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) )
|
curVer = "%02d%02d%02d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) )
|
||||||
|
|
||||||
return ( minVer <= curVer and maxVer >= curVer)
|
return ( minVer <= curVer and maxVer >= curVer)
|
||||||
|
@ -207,11 +207,11 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse qgisMaxVersion. Must be in form x.y.z or just x.y
|
// Parse qgisMaxVersion. Must be in form x.y.z or just x.y
|
||||||
int maxVerMajor, maxVerMinor, maxVerBugfix = 999;
|
int maxVerMajor, maxVerMinor, maxVerBugfix = 99;
|
||||||
if ( maxVersion.isEmpty() || maxVersion == "__error__" )
|
if ( maxVersion.isEmpty() || maxVersion == "__error__" )
|
||||||
{
|
{
|
||||||
maxVerMajor = minVerMajor;
|
maxVerMajor = minVerMajor;
|
||||||
maxVerMinor = 999;
|
maxVerMinor = 99;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -252,16 +252,16 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion
|
|||||||
int qgisMinor = qgisVersionParts.at( 1 ).toInt();
|
int qgisMinor = qgisVersionParts.at( 1 ).toInt();
|
||||||
int qgisBugfix = qgisVersionParts.at( 2 ).toInt();
|
int qgisBugfix = qgisVersionParts.at( 2 ).toInt();
|
||||||
|
|
||||||
// build strings with trailing zeroes
|
// build XxYyZz strings with trailing zeroes if needed
|
||||||
QString minVer = QString( "%1%2%3" ).arg( minVerMajor, 3, 10, QChar( '0' ) )
|
QString minVer = QString( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) )
|
||||||
.arg( minVerMinor, 3, 10, QChar( '0' ) )
|
.arg( minVerMinor, 2, 10, QChar( '0' ) )
|
||||||
.arg( minVerBugfix, 3, 10, QChar( '0' ) );
|
.arg( minVerBugfix, 2, 10, QChar( '0' ) );
|
||||||
QString maxVer = QString( "%1%2%3" ).arg( maxVerMajor, 3, 10, QChar( '0' ) )
|
QString maxVer = QString( "%1%2%3" ).arg( maxVerMajor, 2, 10, QChar( '0' ) )
|
||||||
.arg( maxVerMinor, 3, 10, QChar( '0' ) )
|
.arg( maxVerMinor, 2, 10, QChar( '0' ) )
|
||||||
.arg( maxVerBugfix, 3, 10, QChar( '0' ) );
|
.arg( maxVerBugfix, 2, 10, QChar( '0' ) );
|
||||||
QString curVer = QString( "%1%2%3" ).arg( qgisMajor, 3, 10, QChar( '0' ) )
|
QString curVer = QString( "%1%2%3" ).arg( qgisMajor, 2, 10, QChar( '0' ) )
|
||||||
.arg( qgisMinor, 3, 10, QChar( '0' ) )
|
.arg( qgisMinor, 2, 10, QChar( '0' ) )
|
||||||
.arg( qgisBugfix, 3, 10, QChar( '0' ) );
|
.arg( qgisBugfix, 2, 10, QChar( '0' ) );
|
||||||
|
|
||||||
// compare
|
// compare
|
||||||
return ( minVer <= curVer && maxVer >= curVer);
|
return ( minVer <= curVer && maxVer >= curVer);
|
||||||
|
@ -103,7 +103,7 @@ class QgsPluginRegistry
|
|||||||
bool checkPythonPlugin( QString packageName );
|
bool checkPythonPlugin( QString packageName );
|
||||||
|
|
||||||
//! Check current QGIS version against requested minimal and optionally maximal QGIS version
|
//! Check current QGIS version against requested minimal and optionally maximal QGIS version
|
||||||
//! if maxVersion not specified, the default value is assumed: floor(minVersion) + 0.999.999
|
//! if maxVersion not specified, the default value is assumed: floor(minVersion) + 0.99.99
|
||||||
bool checkQgisVersion( QString minVersion, QString maxVersion = "" );
|
bool checkQgisVersion( QString minVersion, QString maxVersion = "" );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user