summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-10-07 23:39:08 +0200
committerAki <please@ignore.pl>2022-10-07 23:39:08 +0200
commitb17a73f2cb8bb2dcdc4063305ac541441250cf87 (patch)
treee5ccb49e04a0518c2163dc373f52f56e998225bb
parent91945e1b4ba9dd270475cc84675781ea26c0a8b7 (diff)
downloadwindy-b17a73f2cb8bb2dcdc4063305ac541441250cf87.zip
windy-b17a73f2cb8bb2dcdc4063305ac541441250cf87.tar.gz
windy-b17a73f2cb8bb2dcdc4063305ac541441250cf87.tar.bz2
Ordered StrEnum members to allow sorting Levels
-rw-r--r--windy/point_forecast.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/windy/point_forecast.py b/windy/point_forecast.py
index 743d85f..54a10c1 100644
--- a/windy/point_forecast.py
+++ b/windy/point_forecast.py
@@ -19,6 +19,29 @@ def _convert_notation(unit):
class _StrEnum(Enum):
+ def __init__(self, value):
+ self._index = len(self.__class__.__members__)
+
+ def __lt__(self, other):
+ if self.__class__ is other.__class__:
+ return self._index < other._index
+ return NotImplemented
+
+ def __le__(self, other):
+ if self.__class__ is other.__class__:
+ return self._index <= other._index
+ return NotImplemented
+
+ def __gt__(self, other):
+ if self.__class__ is other.__class__:
+ return self._index > other._index
+ return NotImplemented
+
+ def __ge__(self, other):
+ if self.__class__ is other.__class__:
+ return self._index >= other._index
+ return NotImplemented
+
def __str__(self):
return self.value