Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Plugin Installer] Make version compare behaviour unified with the re…
…pository app
  • Loading branch information
borysiasty committed Sep 13, 2013
1 parent f5271a1 commit fd4515e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions python/pyplugin_installer/version_compare.py
Expand Up @@ -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"]
Expand All @@ -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.