Is your feature request related to a problem? Please describe.
Creating simple conditions like a function that returns True-False and having that to the string parser engine could be easier.
Describe the solution you'd like
Proposed syntax:
from redengine.conditions import FuncCond
@FuncCond(syntax="is foo time"):
def is_foo():
return True
# Then use
@FuncTask(start_cond="is foo time & daily")
def do_stuff():
...
The FuncCond could have following parameters:
syntax: (List[re.compile, str], str, re.compile): Syntax(es) that are parsed. Named groups are passed to the function like with BaseCondition.
name: Name of the resulted class, optional. By default the same name as the function.
Describe alternatives you've considered
Alternatively using the standard method:
import re
from pathlib import Path
from redengime.core import BaseCondition
class IsFoo(BaseCondition):
__parsers__ = {
"is foo time": "__init__"
}
def __init__(self):
pass
def __bool__(self):
return True
# Then use
@FuncTask(start_cond="is foo time & daily")
def do_stuff():
...
Is your feature request related to a problem? Please describe. Creating simple conditions like a function that returns True-False and having that to the string parser engine could be easier.
Describe the solution you'd like
Proposed syntax:
The
FuncCond
could have following parameters:syntax
: (List[re.compile, str], str, re.compile): Syntax(es) that are parsed. Named groups are passed to the function like withBaseCondition
.name
: Name of the resulted class, optional. By default the same name as the function.Describe alternatives you've considered
Alternatively using the standard method: