Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle quotes when matching selectors #1104

Merged
merged 2 commits into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ def ns_cfg():

def select_lines(data, namespace):
lines = []

for i, line in enumerate(data.splitlines()):
line = line.rstrip()

trailing_quote = ""
if line and line[-1] in ("'", '"'):
trailing_quote = line[-1]

if line.lstrip().startswith('#'):
# Don't bother with comment only lines
continue
Expand All @@ -99,7 +105,7 @@ def select_lines(data, namespace):
cond = m.group(3)
try:
if eval(cond, namespace, {}):
lines.append(m.group(1))
lines.append(m.group(1) + trailing_quote)
except:
sys.exit('''\
Error: Invalid selector in meta.yaml line %d:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def test_select_lines():
test [abc] # no

test [abc]
test # [abc]
test # [abc] yes
'quoted # [abc] '
"quoted # [abc] yes "
test # stuff [abc] yes
test {{ JINJA_VAR[:2] }}
test {{ JINJA_VAR[:2] }} # stuff [abc] yes
Expand All @@ -28,8 +28,8 @@ def test_select_lines():
test [abc] # no

test
test
test
'quoted'
"quoted"
test
test {{ JINJA_VAR[:2] }}
test {{ JINJA_VAR[:2] }}
Expand Down