Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at de6347c31c28038597016d3db545507f4e9b2cc7 23 lines 686 B view raw
1import re 2 3from osprey.engine.executor.execution_context import ExecutionContext 4from osprey.engine.udf.arguments import ArgumentsBase 5from osprey.engine.udf.base import UDFBase 6 7 8class TextContainsArguments(ArgumentsBase): 9 text: str 10 phrase: str 11 case_sensitive = False 12 13 14class TextContains(UDFBase[TextContainsArguments, bool]): 15 def execute(self, execution_context: ExecutionContext, arguments: TextContainsArguments) -> bool: 16 escaped = re.escape(arguments.phrase) 17 18 pattern = rf'\b{escaped}\b' 19 20 flags = 0 if arguments.case_sensitive else re.IGNORECASE 21 regex = re.compile(pattern, flags) 22 23 return bool(regex.search(arguments.text))