You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
36cc20bf45
Initial commit, not ready for release.
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
# Payment class remains unchanged
|
|
class Payment:
|
|
def __init__(self, epoch_time, amount_sats, comment):
|
|
self.epoch_time = epoch_time
|
|
self.amount_sats = amount_sats
|
|
self.comment = comment
|
|
|
|
def __str__(self):
|
|
sattext = "sats"
|
|
if self.amount_sats == 1:
|
|
sattext = "sat"
|
|
if not self.comment:
|
|
verb = "spent"
|
|
if self.amount_sats > 0:
|
|
verb = "received!"
|
|
return f"{self.amount_sats} {sattext} {verb}"
|
|
#return f"{self.amount_sats} {sattext} @ {self.epoch_time}: {self.comment}"
|
|
return f"{self.amount_sats} {sattext}: {self.comment}"
|
|
|
|
def __eq__(self, other):
|
|
if not isinstance(other, Payment):
|
|
return False
|
|
return self.epoch_time == other.epoch_time and self.amount_sats == other.amount_sats and self.comment == other.comment
|
|
|
|
def __lt__(self, other):
|
|
if not isinstance(other, Payment):
|
|
return NotImplemented
|
|
return (self.epoch_time, self.amount_sats, self.comment) < (other.epoch_time, other.amount_sats, other.comment)
|
|
|
|
def __le__(self, other):
|
|
if not isinstance(other, Payment):
|
|
return NotImplemented
|
|
return (self.epoch_time, self.amount_sats, self.comment) <= (other.epoch_time, other.amount_sats, other.comment)
|
|
|
|
def __gt__(self, other):
|
|
if not isinstance(other, Payment):
|
|
return NotImplemented
|
|
return (self.epoch_time, self.amount_sats, self.comment) > (other.epoch_time, other.amount_sats, other.comment)
|
|
|
|
def __ge__(self, other):
|
|
if not isinstance(other, Payment):
|
|
return NotImplemented
|
|
return (self.epoch_time, self.amount_sats, self.comment) >= (other.epoch_time, other.amount_sats, other.comment)
|