summaryrefslogtreecommitdiff
path: root/src/home/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/util.py')
-rw-r--r--src/home/util.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/home/util.py b/src/home/util.py
index 5050ebb..d5c4229 100644
--- a/src/home/util.py
+++ b/src/home/util.py
@@ -7,9 +7,10 @@ import logging
import string
import random
-from enum import Enum
+from enum import Enum, IntEnum
from datetime import datetime
-from typing import Tuple, Optional, List
+from typing import Tuple, Optional, List, Union
+from zlib import adler32
Addr = Tuple[str, int] # network address type (host, port)
@@ -187,4 +188,9 @@ def filesize_fmt(num, suffix="B") -> str:
if abs(num) < 1024.0:
return f"{num:3.1f} {unit}{suffix}"
num /= 1024.0
- return f"{num:.1f} Yi{suffix}" \ No newline at end of file
+ return f"{num:.1f} Yi{suffix}"
+
+
+class HashableEnum(Enum):
+ def hash(self) -> int:
+ return adler32(self.name.encode()) \ No newline at end of file