80 lines
2.0 KiB
Python
80 lines
2.0 KiB
Python
|
|
class versionIssue(object):
|
||
|
|
|
||
|
|
def __init__(self, strVersion):
|
||
|
|
self.mListSubV = []
|
||
|
|
self.mValid = False
|
||
|
|
self.mStrVersion = strVersion
|
||
|
|
|
||
|
|
strAry = self.mStrVersion.split( "." )
|
||
|
|
if 2 <= len( strAry ):
|
||
|
|
for item in strAry:
|
||
|
|
if not item.isnumeric():
|
||
|
|
return
|
||
|
|
self.mListSubV.append( int( item ) )
|
||
|
|
self.mValid = True
|
||
|
|
|
||
|
|
def valid(self):
|
||
|
|
return self.mValid
|
||
|
|
|
||
|
|
def getVersion(self):
|
||
|
|
return self.mStrVersion
|
||
|
|
|
||
|
|
def biggerThen( self, other ):
|
||
|
|
if not self.valid():
|
||
|
|
return False
|
||
|
|
if not other.valid():
|
||
|
|
return True
|
||
|
|
lenMe = len( self.mListSubV )
|
||
|
|
lenOther = len( other.mListSubV )
|
||
|
|
lenCmp = min( lenMe, lenOther )
|
||
|
|
|
||
|
|
for i in range( lenCmp ):
|
||
|
|
if self.mListSubV[ i ] > other.mListSubV[ i ]:
|
||
|
|
return True
|
||
|
|
elif self.mListSubV[ i ] < other.mListSubV[ i ]:
|
||
|
|
return False
|
||
|
|
return lenMe > lenOther
|
||
|
|
|
||
|
|
def lastVersion(self):
|
||
|
|
if self.valid():
|
||
|
|
|
||
|
|
tpList = []
|
||
|
|
tpList.extend( self.mListSubV )
|
||
|
|
nListLength = len( tpList )
|
||
|
|
tpList[ nListLength - 1 ] -= 1
|
||
|
|
|
||
|
|
strVersion = ""
|
||
|
|
|
||
|
|
for i in range( nListLength ):
|
||
|
|
if 0 != i:
|
||
|
|
strVersion += "."
|
||
|
|
strVersion += str( tpList[i] )
|
||
|
|
|
||
|
|
return versionIssue( strVersion )
|
||
|
|
|
||
|
|
return versionIssue( "" )
|
||
|
|
|
||
|
|
|
||
|
|
def nextVersion(self):
|
||
|
|
if self.valid():
|
||
|
|
|
||
|
|
tpList = []
|
||
|
|
tpList.extend( self.mListSubV )
|
||
|
|
nListLength = len( tpList )
|
||
|
|
tpList[ nListLength - 1 ] += 1
|
||
|
|
|
||
|
|
strVersion = ""
|
||
|
|
|
||
|
|
for i in range( nListLength ):
|
||
|
|
if 0 != i:
|
||
|
|
strVersion += "."
|
||
|
|
strVersion += str( tpList[i] )
|
||
|
|
|
||
|
|
return versionIssue( strVersion )
|
||
|
|
|
||
|
|
return versionIssue( "" )
|
||
|
|
|
||
|
|
def duplicate(self):
|
||
|
|
return versionIssue( self.mStrVersion )
|
||
|
|
|