forked from 5genesis/ELCM
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from EVOLVED-5G/verdict
Verdict
- Loading branch information
Showing
31 changed files
with
273 additions
and
26 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
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
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,25 @@ | ||
from Task import Task | ||
from Helper import Level | ||
import re | ||
|
||
|
||
class Evaluate(Task): | ||
def __init__(self, logMethod, parent, params): | ||
super().__init__("Evaluate", parent, params, logMethod, None) | ||
self.paramRules = { | ||
'Key': (None, True), | ||
'Expression': (None, True) | ||
} | ||
|
||
def Run(self): | ||
expression = self.params["Expression"] | ||
key = self.params["Key"] | ||
self.Log(Level.INFO, f"Evaluating '{key} = {expression}'") | ||
|
||
try: | ||
result = eval(expression) | ||
except Exception as e: | ||
self.Log(Level.ERROR, f"Exception while evaluating expression '{expression}'") | ||
raise e | ||
|
||
self.Publish(key, str(result)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from Task import Task | ||
from Helper import Level | ||
import re | ||
|
||
|
||
class UpgradeVerdict(Task): | ||
def __init__(self, logMethod, parent, params): | ||
super().__init__("Upgrade Verdict", parent, params, logMethod, None) | ||
self.paramRules = { | ||
'Key': (None, True), | ||
'Pattern': (None, True), | ||
'VerdictOnMissing': ("NotSet", False), | ||
'VerdictOnMatch': ("NotSet", False), | ||
'VerdictOnNoMatch': ("NotSet", False), | ||
} | ||
|
||
def Run(self): | ||
from Executor import Verdict | ||
|
||
def _assignVerdict(name: str) -> Verdict | None: | ||
try: | ||
return Verdict[name] | ||
except KeyError: | ||
self.SetVerdictOnError() | ||
self.Log(Level.ERROR, f"Unrecognized Verdict '{name}'") | ||
return None | ||
|
||
onMiss = _assignVerdict(self.params["VerdictOnMissing"]) | ||
onMatch = _assignVerdict(self.params["VerdictOnMatch"]) | ||
onNoMatch = _assignVerdict(self.params["VerdictOnNoMatch"]) | ||
if None in [onMiss, onMatch, onNoMatch]: return | ||
|
||
key = self.params["Key"] | ||
regex = re.compile(self.params["Pattern"]) | ||
collection = self.parent.Params | ||
|
||
if key not in collection.keys(): | ||
self.Log(Level.WARNING, f"Key '{key}' not found. Setting Verdict to '{onMiss.name}'") | ||
self.Log(Level.DEBUG, f"Available keys: {list(collection.keys())}") | ||
self.Verdict = onMiss | ||
else: | ||
value = str(collection[key]) | ||
if regex.match(value): | ||
condition = "matches" | ||
verdict = onMatch | ||
else: | ||
condition = "does not match" | ||
verdict = onNoMatch | ||
|
||
self.Log(Level.INFO, f"'{key}'='{value}' {condition} pattern. Setting Verdict to '{verdict.name}'") | ||
self.Verdict = verdict | ||
|
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.