1
0
SongZihuan 3 жил өмнө
parent
commit
9df01d88ed

+ 0 - 0
src/conf/__init__.py → conf/__init__.py


+ 1 - 0
core/__init__.py

@@ -0,0 +1 @@
+import tool

+ 4 - 4
src/core/garbage.py → core/garbage.py

@@ -1,6 +1,6 @@
+from tool.type_ import *
 from tool.time_ import HGSTime, hgs_time_t
 from tool.location import HGSLocation, hgs_location_t
-from tool.type_ import *
 from enum import Enum
 
 
@@ -41,9 +41,9 @@ class GarbageBag:
         if not isinstance(location, HGSLocation):
             location = HGSLocation(location)
         self._type: enum = garbage_type
-        self._use_time: enum = use_time
-        self._user: enum = user
-        self._loc: enum = location
+        self._use_time: HGSTime = use_time
+        self._user: uid_t = user
+        self._loc: HGSLocation = location
 
     def is_out_of_date(self) -> bool:
         return self.last_time.is_out_of_date()

+ 0 - 0
src/core/user.py → core/user.py


+ 1 - 0
src/main.py → main.py

@@ -1,2 +1,3 @@
 import conf
 import core
+import tool

+ 0 - 0
src/core/tool/__init__.py


+ 0 - 15
src/core/tool/type_.py

@@ -1,15 +0,0 @@
-from typing import Union, TypeAlias
-
-gid_t: TypeAlias = str  # garbage bag id 类型
-uid_t: TypeAlias = str  # user id 类型
-
-uname_t: TypeAlias = str  # user name 类型
-passwd_t: TypeAlias = str  # user password 类型
-
-count_t: TypeAlias = int  # 计数类型 (垃圾计数)
-score_t: TypeAlias = int  # 积分类型
-location_t: TypeAlias = str
-time_t: TypeAlias = float  # 时间类型
-day_t: TypeAlias = int
-
-enum: int  # 枚举类型

+ 0 - 0
src/core/__init__.py → tool/__init__.py


+ 1 - 1
src/core/tool/location.py → tool/location.py

@@ -9,4 +9,4 @@ class HGSLocation:
         return self.loc
 
 
-hgs_location_t: TypeAlias = Union[HGSLocation, location_t]
+hgs_location_t = NewType("hgs_location_t", Union[HGSLocation, location_t])

+ 1 - 1
src/core/tool/login.py → tool/login.py

@@ -1,4 +1,4 @@
-from .type_ import *
+from type_ import *
 import hashlib
 
 

+ 3 - 3
src/core/tool/time_.py → tool/time_.py

@@ -1,11 +1,11 @@
-from .type_ import *
+from type_ import *
 import time
 
 
 class HGSTime:
     def __init__(self, second: time_t = None):
         if second is None:
-            self._time: time_t = time.time()
+            self._time: time_t = time_t(time.time())
         else:
             self._time: time_t = second
         self._time_local: time.struct_time = time.localtime(self._time)
@@ -14,4 +14,4 @@ class HGSTime:
         return time.time() > self._time
 
 
-hgs_time_t: TypeAlias = Union[HGSTime, time_t]
+hgs_time_t = NewType("hgs_time_t", Union[HGSTime, time_t])

+ 15 - 0
tool/type_.py

@@ -0,0 +1,15 @@
+from typing import Dict, Union, NewType
+
+gid_t = NewType("gid_t", str)  # garbage bag id 类型
+uid_t = NewType("uid_t", str)  # user id 类型
+
+uname_t = NewType("uname_t", str)  # user name 类型
+passwd_t = NewType("passwd_t", str)  # user password 类型
+
+count_t = NewType("count_t", int)  # 计数类型 (垃圾计数)
+score_t = NewType("score_t", int)  # 积分类型
+location_t = NewType("location_t", str)
+time_t = NewType("time_t", float)  # 时间类型
+day_t = NewType("day_t", int)
+
+enum = NewType("enum", int)  # 枚举类型