-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f487802
commit ce1700a
Showing
27 changed files
with
753 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 17 additions & 13 deletions
30
packages/iamai-adapter-apscheduler/iamai/adapter/apscheduler/event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
"""APScheduler 适配器事件。""" | ||
from typing import TYPE_CHECKING, Any, Dict, Type | ||
from typing import TYPE_CHECKING, Any, Dict, Optional, Type, Union | ||
|
||
from apscheduler.job import Job | ||
from apscheduler.triggers.base import BaseTrigger | ||
|
||
from iamai.event import Event | ||
from iamai.plugin import Plugin | ||
|
||
if TYPE_CHECKING: | ||
from apscheduler.job import Job | ||
from . import APSchedulerAdapter | ||
|
||
|
||
from . import APSchedulerAdapter # noqa | ||
__all__ = ["APSchedulerEvent"] | ||
|
||
|
||
class APSchedulerEvent(Event["APSchedulerAdapter"]): | ||
"""APSchedulerEvent 事件基类。""" | ||
|
||
type = "apscheduler" | ||
plugin_class: Type[Plugin] | ||
type: Optional[str] = "apscheduler" | ||
plugin_class: Type[Plugin] # type: ignore | ||
|
||
@property | ||
def job(self) -> "Job": | ||
"""产生当前事件的 APScheduler Job 对象。""" | ||
return self.adapter.plugin_class_to_job.get(self.plugin_class) | ||
def job(self) -> Job: | ||
"""产生当前事件的 APScheduler `Job` 对象。""" | ||
return self.adapter.plugin_class_to_job[self.plugin_class] | ||
|
||
@property | ||
def trigger(self) -> str: | ||
"""当前事件对应的 Plugin 的 trigger。""" | ||
return getattr(self.plugin_class, "trigger", None) | ||
def trigger(self) -> Union[str, BaseTrigger]: | ||
"""当前事件对应的 Plugin 的 `trigger`。""" | ||
return getattr(self.plugin_class, "trigger") # noqa: B009 | ||
|
||
@property | ||
def trigger_args(self) -> Dict[str, Any]: | ||
"""当前事件对应的 Plugin 的 trigger_args。""" | ||
return getattr(self.plugin_class, "trigger_args", None) | ||
"""当前事件对应的 Plugin 的 `trigger_args`。""" | ||
return getattr(self.plugin_class, "trigger_args") # noqa: B009 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.