Drop the splitVersionNumber function
This commit is contained in:
@@ -277,33 +277,6 @@ def yesNo(value):
|
||||
return "yes" if value else "no"
|
||||
|
||||
|
||||
def splitVersionNumber(value):
|
||||
"""Split a version string on the form aa.bb.cc into major, minor
|
||||
and patch, and computes an integer value aabbcc.
|
||||
"""
|
||||
if not isinstance(value, str):
|
||||
return 0, 0, 0, 0
|
||||
|
||||
vMajor = 0
|
||||
vMinor = 0
|
||||
vPatch = 0
|
||||
vInt = 0
|
||||
|
||||
vBits = value.split(".")
|
||||
nBits = len(vBits)
|
||||
|
||||
if nBits > 0:
|
||||
vMajor = checkInt(vBits[0], 0)
|
||||
if nBits > 1:
|
||||
vMinor = checkInt(vBits[1], 0)
|
||||
if nBits > 2:
|
||||
vPatch = checkInt(vBits[2], 0)
|
||||
|
||||
vInt = vMajor*10000 + vMinor*100 + vPatch
|
||||
|
||||
return vMajor, vMinor, vPatch, vInt
|
||||
|
||||
|
||||
def transferCase(source, target):
|
||||
"""Transfers the case of the source word to the target word. This
|
||||
will consider all upper or lower, and first char capitalisation.
|
||||
|
||||
@@ -33,9 +33,9 @@ from novelwriter.common import (
|
||||
checkStringNone, checkString, checkInt, checkFloat, checkBool, checkHandle,
|
||||
checkUuid, checkPath, isHandle, isTitleTag, isItemClass, isItemType,
|
||||
isItemLayout, hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp,
|
||||
formatTime, simplified, yesNo, splitVersionNumber, transferCase, fuzzyTime,
|
||||
numberToRoman, jsonEncode, readTextFile, makeFileNameSafe, sha256sum,
|
||||
getGuiItem, NWConfigParser
|
||||
formatTime, simplified, yesNo, transferCase, fuzzyTime, numberToRoman,
|
||||
jsonEncode, readTextFile, makeFileNameSafe, sha256sum, getGuiItem,
|
||||
NWConfigParser
|
||||
)
|
||||
|
||||
|
||||
@@ -398,25 +398,6 @@ def testBaseCommon_YesNo():
|
||||
# END Test testBaseCommon_YesNo
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseCommon_SplitVersionNumber():
|
||||
"""Test the splitVersionNumber function.
|
||||
"""
|
||||
# OK Values
|
||||
assert splitVersionNumber("1") == (1, 0, 0, 10000)
|
||||
assert splitVersionNumber("1.2") == (1, 2, 0, 10200)
|
||||
assert splitVersionNumber("1.2.3") == (1, 2, 3, 10203)
|
||||
assert splitVersionNumber("1.2.3.4") == (1, 2, 3, 10203)
|
||||
assert splitVersionNumber("99.99.99") == (99, 99, 99, 999999)
|
||||
|
||||
# Failed Values
|
||||
assert splitVersionNumber(None) == (0, 0, 0, 0)
|
||||
assert splitVersionNumber(1234) == (0, 0, 0, 0)
|
||||
assert splitVersionNumber("1.2abc") == (1, 0, 0, 10000)
|
||||
|
||||
# END Test testBaseCommon_SplitVersionNumber
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseCommon_FormatInt():
|
||||
"""Test the formatInt function.
|
||||
|
||||
Reference in New Issue
Block a user