diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pydrilla/pydrilla.py | 45 | ||||
-rw-r--r-- | src/test/test_pydrilla.py | 36 |
2 files changed, 0 insertions, 81 deletions
diff --git a/src/pydrilla/pydrilla.py b/src/pydrilla/pydrilla.py index caf05a2..b5513b9 100644 --- a/src/pydrilla/pydrilla.py +++ b/src/pydrilla/pydrilla.py @@ -157,51 +157,6 @@ def version_string(ver, rev=None): ''' return '.'.join([str(n) for n in ver]) + ('' if rev is None else f'-{rev}') -### pad_versions() and compare_versions() likely won't be needed - -# def pad_versions(ver1, ver2): -# ''' -# Each of the arguments is an array of integers. If one of the arrays is -# shorter than the other, right-pad it with zeroes to make it the same -# length as the other one. - -# Returns a tuple of *new* arrays. Doesn't modify its arguments. -# ''' -# if len(ver1) < len(ver2): -# ver2, ver1 = pad_versions(ver2, ver1) -# else: -# ver2 = [*ver2, *([0] * (len(ver1) - len(ver2)))] -# ver1 = [*ver1] - -# return ver1, ver2 - -# def compare_versions(ver1, ver2, rev1=1, rev2=1): -# ''' -# ver1 and ver2 are arrays of integers, with major version number being the -# first array item. If versions specified by arrays of different length need -# to be compared, the shorter array gets padded with zeroes on the right. -# This means that for example version 1.3 could be given as both [1, 3] and -# [1, 3, 0, 0] (aka 1.3.0.0) and either would mean the same. - -# rev1 and rev2 are revision numbers. They are appended to padded ver1 and -# ver2 arrays respectively before comparison. - -# This function returns -1, 0 or 1 when the first ver1 designates -# respectively a version lower than, equal to or greater than the one in -# ver2. -# ''' -# ver1, ver2 = pad_versions(ver1, ver2) -# ver1.append(rev1) -# ver2.append(rev2) - -# for n1, n2 in zip(ver1, ver2): -# if n1 < n2: -# return -1 -# if n1 > n2: -# return 1 - -# return 0 - class VersionedContentItem: '''Stores definitions of multiple versions of website content item.''' def __init__(self): diff --git a/src/test/test_pydrilla.py b/src/test/test_pydrilla.py index 0ed5fa9..5937db9 100644 --- a/src/test/test_pydrilla.py +++ b/src/test/test_pydrilla.py @@ -52,39 +52,3 @@ def test_normalize_version(): assert pydrilla.normalize_version([4, 5, 3, 0, 0]) == [4, 5, 3] assert pydrilla.normalize_version([1, 0, 5, 0]) == [1, 0, 5] assert pydrilla.normalize_version([3, 3]) == [3, 3] - -### pad_versions() and compare_versions() likely won't be needed - -# def test_compare_versions(): -# compare_versions = pydrilla.compare_versions -# # without revision -# assert compare_versions([43], [43]) == 0 -# assert compare_versions([54], [34]) == 1 -# assert compare_versions([1], [3]) == -1 -# assert compare_versions([10, 2], [10, 2]) == 0 -# assert compare_versions([11, 6], [11, 2]) == 1 -# assert compare_versions([3, 0], [3, 8]) == -1 -# assert compare_versions([1, 2, 3], [1, 2]) == 1 -# assert compare_versions([1, 2], [1, 2, 3]) == -1 -# assert compare_versions([1], [1, 0, 0]) == 0 - -# # with revision -# assert compare_versions([43], [43], rev2=3) == -1 -# assert compare_versions([54], [34]), rev2=41) == 1 -# assert compare_versions([1], [3]), rev1=6) == -1 -# assert compare_versions([10, 2], [10, 2]), rev1=8, rev2=5) == 1 -# assert compare_versions([11, 6], [11, 2]), rev2=19) == 1 -# assert compare_versions([3, 0], [3, 8]), rev2=5) == -1 -# assert compare_versions([1, 2, 3], [1, 2]), rev1=4) == 1 -# assert compare_versions([1, 2], [1, 2, 3]), rev2=7) == -1 -# assert compare_versions([1], [1, 0, 0]), rev2=9, rev1=9) == 0 - -# from functools import cmp_to_key - -# versions = [[43], [54], [3, 0], [34], [3], [1], [4, 5, 3], [1, 0, 5], -# [3, 3], [10, 2], [11, 2], [11, 6], [3, 8], [1, 2], [1, 2, 3], -# [1, 0, 0]] -# versions.sort(cmp_to_key(compare_versions)) -# assert versions == [[1], [1, 0, 0], [1, 0, 5], [1, 2], [1, 2, 3], [3, 0], -# [3], [3, 3], [3, 8], [4, 5, 3], [10, 2], [11, 2], -# [11, 6], [34], [43], [54]] |