diff options
| author | Brian Potchik <brian@vector35.com> | 2025-03-06 19:54:50 -0500 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2025-03-06 19:54:50 -0500 |
| commit | ef97d4703cfd08a4ccc3c00dac7cf84877875245 (patch) | |
| tree | d8687be219e325cd619ada7acfaf694a6627af1c /python | |
| parent | 5192206454838298978583761915446906174711 (diff) | |
Add API to insert Activities after a specified Activity.
Diffstat (limited to 'python')
| -rw-r--r-- | python/workflow.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/python/workflow.py b/python/workflow.py index 7eed81c1..063321af 100644 --- a/python/workflow.py +++ b/python/workflow.py @@ -487,7 +487,7 @@ class Workflow(metaclass=_WorkflowMetaclass): """ return core.BNWorkflowClear(self.handle) - def insert(self, activity: ActivityType, activities: List[str]) -> bool: + def insert(self, activity: ActivityType, activities: Union[List[str], str]) -> bool: """ ``insert`` Insert the list of ``activities`` before the specified ``activity`` and at the same level. @@ -496,11 +496,29 @@ class Workflow(metaclass=_WorkflowMetaclass): :return: True on success, False otherwise :rtype: bool """ + if isinstance(activities, str): + activities = [activities] input_list = (ctypes.c_char_p * len(activities))() for i in range(0, len(activities)): input_list[i] = str(activities[i]).encode('charmap') return core.BNWorkflowInsert(self.handle, str(activity), input_list, len(activities)) + def insert_after(self, activity: ActivityType, activities: Union[List[str], str]) -> bool: + """ + ``insert_after`` Insert the list of ``activities`` after the specified ``activity`` and at the same level. + + :param str activity: the Activity node for which to insert ``activities`` after + :param list[str] activities: the list of Activities to insert + :return: True on success, False otherwise + :rtype: bool + """ + if isinstance(activities, str): + activities = [activities] + input_list = (ctypes.c_char_p * len(activities))() + for i in range(0, len(activities)): + input_list[i] = str(activities[i]).encode('charmap') + return core.BNWorkflowInsertAfter(self.handle, str(activity), input_list, len(activities)) + def remove(self, activity: ActivityType) -> bool: """ ``remove`` Remove the specified ``activity``. |
