From 5537bd7d4a3ab7913c546c9b1b2fa69bfb96b62a Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Mon, 21 Jul 2025 14:19:27 +0800 Subject: [PATCH] Save --- .vscode/settings.json | 3 +++ Convention/Runtime/Config.py | 18 +++++++++--------- [Test]/test.py | 15 +++++++-------- 3 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff5300e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.languageServer": "None" +} \ No newline at end of file diff --git a/Convention/Runtime/Config.py b/Convention/Runtime/Config.py index 2bab59e..4b88c6b 100644 --- a/Convention/Runtime/Config.py +++ b/Convention/Runtime/Config.py @@ -121,12 +121,12 @@ def ReadAssemblyTypen( class ActionEvent[_Call:Callable]: def __init__(self, actions:Sequence[_Call]): super().__init__() - self.__actions: List[Callable] = [action for action in actions] + self._actions: List[Callable] = [action for action in actions] self.call_indexs: List[int] = [i for i in range(len(actions))] self.last_result: List[Any] = [] def CallFuncWithoutCallIndexControl(self, index:int, *args, **kwargs) -> Union[Any, Exception]: try: - return self.__actions[index](*args, **kwargs) + return self._actions[index](*args, **kwargs) except Exception as ex: return ex def CallFunc(self, index:int, *args, **kwargs) -> Union[Any, Exception]: @@ -140,19 +140,19 @@ class ActionEvent[_Call:Callable]: self.last_result = self._InjectInvoke(*args, **kwargs) return self def InitCallIndex(self): - self.call_indexs = [i for i in range(len(self.__actions))] + self.call_indexs = [i for i in range(len(self._actions))] def AddAction(self, action:_Call): - self.__actions.append(action) - self.call_indexs.append(len(self.__actions)-1) + self._actions.append(action) + self.call_indexs.append(len(self._actions)-1) return self def AddActions(self, actions:Sequence[_Call]): for action in actions: self.AddAction(action) return self def _InternalRemoveAction(self, action:_Call): - if action in self.__actions: - index = self.__actions.index(action) - self.__actions.remove(action) + if action in self._actions: + index = self._actions.index(action) + self._actions.remove(action) self.call_indexs.remove(index) for i in range(len(self.call_indexs)): if self.call_indexs[i] > index: @@ -172,7 +172,7 @@ class ActionEvent[_Call:Callable]: return len(self.call_indexs) @property def ActionCount(self): - return len(self.__actions) + return len(self._actions) # region instance diff --git a/[Test]/test.py b/[Test]/test.py index 8da0678..401610f 100644 --- a/[Test]/test.py +++ b/[Test]/test.py @@ -5,16 +5,15 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from Convention.Runtime.Config import * from Convention.Runtime.EasySave import * -class test_log(BaseModel): - test_field:int - test_field_2:str +class Test: + test_field:int = 10 + class_test_field:int = 20 + + def __init__(self): + self.test_field:int = 0 def run(): - SetInternalDebug(True) - SetInternalReflectionDebug(True) - SetInternalEasySaveDebug(True) - test = test_log(test_field=1,test_field_2="test") - EasySave.Write(test,"test.json") + print(Test.__annotations__) if __name__ == "__main__": run()