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

PICARD-922: Fix inmulti behaviour with multi-values #623

Merged
merged 4 commits into from Feb 15, 2017

Conversation

antlarr
Copy link
Contributor

@antlarr antlarr commented Feb 12, 2017

inmulti arguments where evaluated before inmulti was executed, which
resulted in strings being passed as arguments, which breaks cases in which
the strings in multivalue variables contain the separator used to separate
multiple values (see PICARD-922).
This commit fixes the behaviour of inmulti so arguments are not evaluated
before they're passed, so it can extract the argument value as a list and
work with that.
This fixes https://tickets.metabrainz.org/browse/PICARD-922

Add a test to check that the inmulti function works as expected.
inmulti arguments where evaluated before inmulti was executed, which
resulted in strings being passed as arguments, which breaks cases in which
the strings in multivalue variables contain the separator used to separate
multiple values (see PICARD-922).
This commit changes the behaviour of inmulti so arguments are not evaluated
before they're passed, so it can extract the argument value as a list and
work with that.
This should fix PICARD-922
picard/script.py Outdated
In both cases, it returns true if the resulting list contains ``needle``."""

needle = needle.eval(parser)
if type(text)==ScriptExpression and len(text)==1 and type(text[0])==ScriptVariable:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer using isinstance() here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the code through a pep8 checker and fix any errors :)

picard/script.py Outdated
needle = needle.eval(parser)
if type(text)==ScriptExpression and len(text)==1 and type(text[0])==ScriptVariable:
text=text[0]
if type(text)==ScriptVariable:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

picard/script.py Outdated
name = u"~" + text.name[1:]
else:
name = text.name
values=parser.context.getall(name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8, please put spaces around "="

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text not defined? I think you mean haystack.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests seem to be failing because of the above.

@samj1912
Copy link
Collaborator

Please edit the PR title with PICARD-922 and add a link to jira :)

Add a few empty lines and wrap some lines so they're not so large
The text variable was renamed to haystack except in some lines.
This commit fixes this and also fixes some coding style issues.
@antlarr antlarr changed the title Fix inmulti behaviour with multi-values PICARD-922: Fix inmulti behaviour with multi-values Feb 13, 2017
@zas zas merged commit 02c0561 into metabrainz:master Feb 15, 2017
Sophist-UK added a commit to Sophist-UK/picard that referenced this pull request Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants