Add __gt__ and mkFileStr function to File class.

This commit is contained in:
Kevin Baensch 2024-11-23 23:17:17 +01:00
parent 0ad9ec320a
commit 82e1d2b3af
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -1,4 +1,4 @@
from typing import Optional from typing import Optional, Self
from os import path from os import path
from . import cktype from . import cktype
@ -7,6 +7,7 @@ class FILE:
""" """
Colored checkmark representation. Colored checkmark representation.
""" """
CHECKMARK = { CHECKMARK = {
True: "\033[92m✓\033[0m", True: "\033[92m✓\033[0m",
False: "\033[91m❌\033[0m", False: "\033[91m❌\033[0m",
@ -19,9 +20,15 @@ class FILE:
# TODO: Move out expected sum calculation # TODO: Move out expected sum calculation
self.csum, self.esum = cktype.resolve(self.fname, esum, cstype) self.csum, self.esum = cktype.resolve(self.fname, esum, cstype)
def __repr__(self): def __repr__(self) -> str:
return self.fname return self.fname
def __gt__(self, other: Self) -> bool:
return self.__repr__() > other.__repr__()
def mkFileStr(self) -> str:
return f"{self.csum}\t{self.fname}\n"
def verify(self) -> Optional[bool]: def verify(self) -> Optional[bool]:
if self.esum is None: if self.esum is None:
return None return None