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
Conversation
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 "="
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
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