Skip to content

Commit

Permalink
per #1534, fix logic to properly preserving trailing semi-colon from …
Browse files Browse the repository at this point in the history
…list if it is not following square brackets []s
  • Loading branch information
georgemccabe committed Apr 18, 2022
1 parent c46767e commit e2798a4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions metplus/util/string_manip.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ def getlist(list_str, expand_begin_end_incr=True):
if not list_str:
return []

# FIRST remove surrounding comma, and spaces, form the string.
list_str = list_str.strip(';[] ').strip().strip(',').strip()
# remove surrounding comma and spaces from the string
list_str = list_str.strip(', ')

# remove trailing semi-colon IF found after []s
if list_str.endswith('];'):
list_str = list_str.strip('; ')

# remove [ from start (left) and ] from end (right)
list_str = list_str.lstrip('[ ').rstrip('] ')

# remove space around commas
list_str = re.sub(r'\s*,\s*', ',', list_str)
Expand Down

0 comments on commit e2798a4

Please sign in to comment.