-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from r3w0p/1.1
1.1
- Loading branch information
Showing
33 changed files
with
977 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
branches: | ||
- 'main' | ||
tags-ignore: | ||
- '**' | ||
|
||
jobs: | ||
ci: | ||
|
@@ -46,7 +48,7 @@ jobs: | |
- name: Documentation coverage with interrogate | ||
run: | | ||
interrogate -vv bobocep --fail-under 98 | ||
interrogate -vv bobocep --fail-under 100 | ||
- name: Upload code coverage to Code Climate | ||
uses: paambaati/[email protected] | ||
|
@@ -87,7 +89,6 @@ jobs: | |
--outdir dist/ | ||
- name: Publish to PyPI | ||
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} |
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
branches: | ||
- 'main' | ||
tags-ignore: | ||
- '**' | ||
schedule: | ||
# At 06:00 on Monday. | ||
- cron: '0 6 * * 1' | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
|
||
__author__ = """r3w0p""" | ||
__email__ = "[email protected]" | ||
__version__ = "1.0.1" | ||
__version__ = "1.1.0" | ||
|
||
from bobocep.bobocep import BoboError | ||
from bobocep.bobocep import BoboError, BoboJSONable, BoboJSONableError |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2019-2023 r3w0p | ||
# The following code can be redistributed and/or | ||
# modified under the terms of the MIT License. | ||
|
||
""" | ||
Common actions. | ||
""" |
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright (c) 2019-2023 r3w0p | ||
# The following code can be redistributed and/or | ||
# modified under the terms of the MIT License. | ||
|
||
""" | ||
Multi actions. | ||
""" | ||
from abc import ABC | ||
from typing import Tuple, Any, List | ||
|
||
from bobocep.cep.action import BoboAction, BoboActionError | ||
from bobocep.cep.event import BoboEventComplex | ||
|
||
_ACTIONS_MIN: int = 1 | ||
|
||
|
||
class BoboActionMulti(BoboAction, ABC): | ||
""" | ||
An abstract multi action. | ||
""" | ||
|
||
def __init__(self, name: str, *args, **kwargs): | ||
""" | ||
:param name: The action name. | ||
:param args: Action arguments. | ||
:param kwargs: Action keyword arguments. | ||
""" | ||
super().__init__(name=name, args=args, kwargs=kwargs) | ||
|
||
|
||
class BoboActionMultiSequential(BoboActionMulti): | ||
""" | ||
An abstract sequential multi action. | ||
""" | ||
|
||
def __init__(self, | ||
name: str, | ||
actions: List[BoboAction], | ||
stop_on_fail: bool, | ||
*args, | ||
**kwargs): | ||
""" | ||
:param name: The action name. | ||
:param actions: The list of actions to execute. | ||
:param stop_on_fail: If True, the multi-action stops processing its | ||
action list if its current action fails. If False, it continues | ||
to process its remaining actions. Note: failure of any action in | ||
its list will cause the multi-action's success to be False. | ||
:param args: Action arguments. | ||
:param kwargs: Action keyword arguments. | ||
""" | ||
super().__init__(name=name, args=args, kwargs=kwargs) | ||
|
||
if len(actions) < 1: | ||
raise BoboActionError( | ||
f"multi sequential action {name} " | ||
f"must contain at least {_ACTIONS_MIN} action") | ||
|
||
self._actions: List[BoboAction] = actions | ||
self._stop_on_fail: bool = stop_on_fail | ||
|
||
def execute(self, event: BoboEventComplex) \ | ||
-> Tuple[bool, List[Tuple[bool, Any]]]: | ||
""" | ||
:param event: The complex event that triggered action. | ||
:return: Whether the action execution was successful, and | ||
any additional data. | ||
""" | ||
success = True | ||
data: List[Tuple[bool, Any]] = [] | ||
|
||
for action in self._actions: | ||
output: Tuple[bool, Any] = action.execute(event) | ||
data.append(output) | ||
|
||
# If action was unsuccessful | ||
if not output[0]: | ||
success = False | ||
|
||
if self._stop_on_fail: | ||
break | ||
|
||
return success, data |
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
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
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.