Drop the splitVersionNumber function

This commit is contained in:
Veronica Berglyd Olsen
2023-01-29 02:14:21 +01:00
parent 0c75a53e57
commit 1437659a4e
2 changed files with 3 additions and 49 deletions
-27
View File
@@ -277,33 +277,6 @@ def yesNo(value):
return "yes" if value else "no" 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): def transferCase(source, target):
"""Transfers the case of the source word to the target word. This """Transfers the case of the source word to the target word. This
will consider all upper or lower, and first char capitalisation. will consider all upper or lower, and first char capitalisation.
+3 -22
View File
@@ -33,9 +33,9 @@ from novelwriter.common import (
checkStringNone, checkString, checkInt, checkFloat, checkBool, checkHandle, checkStringNone, checkString, checkInt, checkFloat, checkBool, checkHandle,
checkUuid, checkPath, isHandle, isTitleTag, isItemClass, isItemType, checkUuid, checkPath, isHandle, isTitleTag, isItemClass, isItemType,
isItemLayout, hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp, isItemLayout, hexToInt, minmax, checkIntTuple, formatInt, formatTimeStamp,
formatTime, simplified, yesNo, splitVersionNumber, transferCase, fuzzyTime, formatTime, simplified, yesNo, transferCase, fuzzyTime, numberToRoman,
numberToRoman, jsonEncode, readTextFile, makeFileNameSafe, sha256sum, jsonEncode, readTextFile, makeFileNameSafe, sha256sum, getGuiItem,
getGuiItem, NWConfigParser NWConfigParser
) )
@@ -398,25 +398,6 @@ def testBaseCommon_YesNo():
# END Test 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 @pytest.mark.base
def testBaseCommon_FormatInt(): def testBaseCommon_FormatInt():
"""Test the formatInt function. """Test the formatInt function.