Commit 0c117243 authored by Robert Bradshaw's avatar Robert Bradshaw

Minor distutils parsing fixes.

--HG--
extra : transplant_source : %9A%21%CF%D0vx%24%DE%901o%EA%9B%F7%14-5%F6%20%0F
parent 9eda34cf
...@@ -24,6 +24,16 @@ def cached_method(f): ...@@ -24,6 +24,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 = ','
...@@ -32,12 +42,11 @@ def parse_list(s): ...@@ -32,12 +42,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