Skip to content

Commit 6dd1de1

Browse files
committed
Flatten debug_publish_current_action
1 parent 1b344f2 commit 6dd1de1

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

Diff for: dynamic_stack_decider/dynamic_stack_decider/dsd.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -373,21 +373,23 @@ def debug_publish_current_action(self):
373373
"""
374374
Publishes the name of the currently active action
375375
"""
376-
if self.debug_active:
377-
# Check if there is something on the stack
378-
if len(self.stack) > 0:
379-
# Get the top element
380-
stack_top = self.stack[-1][1]
381-
# Check if it is an action or a sequence element and retrieve the current action
382-
if isinstance(stack_top, AbstractActionElement):
383-
current_action = stack_top
384-
elif isinstance(stack_top, SequenceElement):
385-
current_action = stack_top.current_action
386-
else:
387-
return
388-
# Only publish if the action changed
389-
if current_action.name != self.debug_active_action_cache:
390-
# Publish the name of the current action
391-
self.debug_current_action_publisher.publish(String(data=current_action.name))
392-
# Cache the current action name
393-
self.debug_active_action_cache = current_action.name
376+
# Check if debugging is active and if there is something on the stack
377+
if not self.debug_active or len(self.stack) == 0:
378+
return
379+
380+
# Get the top element
381+
stack_top = self.stack[-1][1]
382+
# Check if it is an action or a sequence element and retrieve the current action
383+
if isinstance(stack_top, AbstractActionElement):
384+
current_action = stack_top
385+
elif isinstance(stack_top, SequenceElement):
386+
current_action = stack_top.current_action
387+
else:
388+
return
389+
390+
# Only publish if the action changed
391+
if current_action.name != self.debug_active_action_cache:
392+
# Publish the name of the current action
393+
self.debug_current_action_publisher.publish(String(data=current_action.name))
394+
# Cache the current action name
395+
self.debug_active_action_cache = current_action.name

Diff for: dynamic_stack_decider/dynamic_stack_decider/tree.py

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def __init__(self, name, parent, parameters=None, unset_parameters=None):
8686
:param parent: the parent element, None for the root element
8787
:param parameters: A dictionary of parameters
8888
:param unset_parameters: A dictionary of parameters that must be set later
89-
:type parent: DecisionTreeElement
9089
"""
9190
# Call the constructor of the superclass
9291
super().__init__(name, parent, parameters, unset_parameters)
@@ -185,7 +184,6 @@ def __init__(self, name, parent, parameters=None, unset_parameters=None):
185184
Create a new ActionTreeElement
186185
:param name: the class name of the corresponding AbstractActionElement
187186
:param parent: the parent element
188-
:type parent: DecisionTreeElement
189187
:param parameters: A dictionary of parameters
190188
:param unset_parameters: A dictionary of parameters that must be set later
191189
"""

0 commit comments

Comments
 (0)