Add version parser

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
nathom 2021-06-16 14:20:16 -07:00
parent 3bd9c815f3
commit 1e1e3c7062

View file

@ -361,3 +361,24 @@ def get_container(quality: int, source: str) -> str:
return "AAC" return "AAC"
return "MP3" return "MP3"
class Version:
def __init__(self, version: str):
self.value = tuple(map(int, version.split(".")))
def __gt__(self, other) -> bool:
assert isinstance(other, Version)
for v1, v2 in zip(self.value, other.value):
if v1 > v2:
return True
elif v1 < v2:
return False
return False
def __lt__(self, other) -> bool:
return not self.__gt__(other) and not self.__eq__(other)
def __eq__(self, other) -> bool:
assert isinstance(other, Version)
return all(v1 == v2 for v1, v2 in zip(self.value, other.value))