Save
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"python.languageServer": "None"
|
||||||
|
}
|
@@ -121,12 +121,12 @@ def ReadAssemblyTypen(
|
|||||||
class ActionEvent[_Call:Callable]:
|
class ActionEvent[_Call:Callable]:
|
||||||
def __init__(self, actions:Sequence[_Call]):
|
def __init__(self, actions:Sequence[_Call]):
|
||||||
super().__init__()
|
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.call_indexs: List[int] = [i for i in range(len(actions))]
|
||||||
self.last_result: List[Any] = []
|
self.last_result: List[Any] = []
|
||||||
def CallFuncWithoutCallIndexControl(self, index:int, *args, **kwargs) -> Union[Any, Exception]:
|
def CallFuncWithoutCallIndexControl(self, index:int, *args, **kwargs) -> Union[Any, Exception]:
|
||||||
try:
|
try:
|
||||||
return self.__actions[index](*args, **kwargs)
|
return self._actions[index](*args, **kwargs)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return ex
|
return ex
|
||||||
def CallFunc(self, index:int, *args, **kwargs) -> Union[Any, Exception]:
|
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)
|
self.last_result = self._InjectInvoke(*args, **kwargs)
|
||||||
return self
|
return self
|
||||||
def InitCallIndex(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):
|
def AddAction(self, action:_Call):
|
||||||
self.__actions.append(action)
|
self._actions.append(action)
|
||||||
self.call_indexs.append(len(self.__actions)-1)
|
self.call_indexs.append(len(self._actions)-1)
|
||||||
return self
|
return self
|
||||||
def AddActions(self, actions:Sequence[_Call]):
|
def AddActions(self, actions:Sequence[_Call]):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
self.AddAction(action)
|
self.AddAction(action)
|
||||||
return self
|
return self
|
||||||
def _InternalRemoveAction(self, action:_Call):
|
def _InternalRemoveAction(self, action:_Call):
|
||||||
if action in self.__actions:
|
if action in self._actions:
|
||||||
index = self.__actions.index(action)
|
index = self._actions.index(action)
|
||||||
self.__actions.remove(action)
|
self._actions.remove(action)
|
||||||
self.call_indexs.remove(index)
|
self.call_indexs.remove(index)
|
||||||
for i in range(len(self.call_indexs)):
|
for i in range(len(self.call_indexs)):
|
||||||
if self.call_indexs[i] > index:
|
if self.call_indexs[i] > index:
|
||||||
@@ -172,7 +172,7 @@ class ActionEvent[_Call:Callable]:
|
|||||||
return len(self.call_indexs)
|
return len(self.call_indexs)
|
||||||
@property
|
@property
|
||||||
def ActionCount(self):
|
def ActionCount(self):
|
||||||
return len(self.__actions)
|
return len(self._actions)
|
||||||
|
|
||||||
# region instance
|
# region instance
|
||||||
|
|
||||||
|
@@ -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.Config import *
|
||||||
from Convention.Runtime.EasySave import *
|
from Convention.Runtime.EasySave import *
|
||||||
|
|
||||||
class test_log(BaseModel):
|
class Test:
|
||||||
test_field:int
|
test_field:int = 10
|
||||||
test_field_2:str
|
class_test_field:int = 20
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.test_field:int = 0
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
SetInternalDebug(True)
|
print(Test.__annotations__)
|
||||||
SetInternalReflectionDebug(True)
|
|
||||||
SetInternalEasySaveDebug(True)
|
|
||||||
test = test_log(test_field=1,test_field_2="test")
|
|
||||||
EasySave.Write(test,"test.json")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
|
Reference in New Issue
Block a user