Skip to content

Commit

Permalink
stateengine plugin: minor internal code update
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Sep 28, 2024
1 parent b8c4ee4 commit cb431df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions stateengine/StateEngineActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def update(self, attribute, value):
return _count, _issue
elif isinstance(value, str):
value = ":".join(map(str.strip, value.split(":")))
if value[:1] == '[' and value[-1:] == ']':
value = StateEngineTools.convert_str_to_list(value, False)
value = StateEngineTools.convert_str_to_list(value, False)
if name in self.__actions:
self.__actions[name].update_action_details(self.__state, self.__action_type)
if func == "se_delay":
Expand Down Expand Up @@ -388,8 +387,7 @@ def remove_action(e):
entry = list("{!s}:{!s}".format(k, v) for (k, v) in entry.items())[0]
key, val = StateEngineTools.partition_strip(entry, ":")
val = ":".join(map(str.strip, val.split(":")))
if val[:1] == '[' and val[-1:] == ']':
val = StateEngineTools.convert_str_to_list(val, False)
val = StateEngineTools.convert_str_to_list(val, False)
if key == "function":
parameter[key] = StateEngineTools.cast_str(val)
elif key == "force":
Expand Down
4 changes: 4 additions & 0 deletions stateengine/StateEngineTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ def partition_strip(value, splitchar):
# returns: list or original value
def convert_str_to_list(value, force=True):
if isinstance(value, str):
orig_value = value
value = value.strip()
if value.startswith('[') and value.endswith(']'):
value = value[1:-1].strip()
else:
return orig_value

if isinstance(value, str) and "," in value:
try:
elements = re.findall(r"'([^']*)'|\"([^\"]*)\"|([^,]+)", value)
Expand Down

0 comments on commit cb431df

Please sign in to comment.