Skip to content
Permalink
Browse files

[Plugin Installer] Make version compare behaviour unified with the re…

…pository app
  • Loading branch information
borysiasty committed Sep 13, 2013
1 parent f5271a1 commit fd4515e22a4c7300b821145709cf1f688e9b25c4
Showing with 8 additions and 10 deletions.
  1. +8 −10 python/pyplugin_installer/version_compare.py
@@ -169,17 +169,15 @@ def splitVersion(s):
return l


def isCompatible(curVer, minVer, maxVer=None):
def isCompatible(curVer, minVer, maxVer):
""" Compare current QGIS version with qgisMinVersion and qgisMaxVersion """
minVer = splitVersion( re.sub(r'[^0-9.]+', '', minVer) )
maxVer = splitVersion( re.sub(r'[^0-9.]+', '', maxVer) )
curVer = splitVersion( re.sub(r'[^0-9.]+', '', curVer) )

if not minVer or not curVer:
if not minVer or not curVer or not maxVer:
return False

if not maxVer:
maxVer = [minVer[0], "99", "99"]
minVer = splitVersion( re.sub(r'[^0-9.]+', '', minVer) )
maxVer = splitVersion( re.sub(r'[^0-9.]+', '', maxVer) )
curVer = splitVersion( re.sub(r'[^0-9.]+', '', curVer) )

if len(minVer)<3:
minVer += ["0"]
@@ -190,8 +188,8 @@ def isCompatible(curVer, minVer, maxVer=None):
if len(maxVer)<3:
maxVer += ["99"]

minVer = "%02d%02d%02d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) )
maxVer = "%02d%02d%02d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) )
curVer = "%02d%02d%02d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) )
minVer = "%04d%04d%04d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) )
maxVer = "%04d%04d%04d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) )
curVer = "%04d%04d%04d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) )

return ( minVer <= curVer and maxVer >= curVer)

0 comments on commit fd4515e

Please sign in to comment.
You can’t perform that action at this time.