Commit 8a646021 authored by Robert Bradshaw's avatar Robert Bradshaw

Minor distutils parsing fixes.

parent 278cc338
...@@ -22,6 +22,16 @@ def cached_method(f): ...@@ -22,6 +22,16 @@ def cached_method(f):
def parse_list(s): def parse_list(s):
"""
>>> parse_list("a b c")
['a', 'b', 'c']
>>> parse_list("[a, b, c]")
['a', 'b', 'c']
>>> parse_list('a " " b')
['a', ' ', 'b']
>>> parse_list('[a, ",a", "a,", ",", ]')
['a', ',a', 'a,', ',']
"""
if s[0] == '[' and s[-1] == ']': if s[0] == '[' and s[-1] == ']':
s = s[1:-1] s = s[1:-1]
delimiter = ',' delimiter = ','
...@@ -30,12 +40,11 @@ def parse_list(s): ...@@ -30,12 +40,11 @@ def parse_list(s):
s, literals = strip_string_literals(s) s, literals = strip_string_literals(s)
def unquote(literal): def unquote(literal):
literal = literal.strip() literal = literal.strip()
if literal[0] == "'": if literal[0] in "'\"":
return literals[literal[1:-1]] return literals[literal[1:-1]]
else: else:
return literal return literal
return [unquote(item) for item in s.split(delimiter) if item.strip()]
return [unquote(item) for item in s.split(delimiter)]
transitive_str = object() transitive_str = object()
transitive_list = object() transitive_list = object()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment