Skip to content

Commit

Permalink
wmltools: add function for comma-splitting values
Browse files Browse the repository at this point in the history
  • Loading branch information
groggyd88 committed Feb 24, 2015
1 parent 41c7d16 commit fba0249
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data/tools/wesnoth/wmltools.py
Expand Up @@ -52,6 +52,16 @@ def attr_strip(value):
value = value.strip()
return string_strip(value)

def comma_split(value, list=None):
"Split a comma-separated value, and append the entries to a list if specified."
vallist = [x.lstrip()for x in value.split(",")]
# lstrip: wml-tags.lua split function will remove leading whitespace
# of items in comma-separated lists but not trailing whitespace
if list:
list.extend(vallist)
else:
return vallist

def parse_attribute(line):
"Parse a WML key-value pair from a line."
if '=' not in line or line.find("#") > -1 and line.find("#") < line.find("="):
Expand Down

0 comments on commit fba0249

Please sign in to comment.