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

Replace Forbidden Windows Symbols Plugin #232

Merged
merged 5 commits into from Aug 26, 2019

Conversation

@AlexRustler
Copy link
Contributor

commented Aug 24, 2019

Replace forbidden symbols :, , /, ? etc with similar Unicode symbols.

AlexRustler added 2 commits Aug 24, 2019
@zas
Copy link
Collaborator

left a comment

You may fix syntax (whitespaces, tabs, whitelines) according to PEP8.

@phw
phw approved these changes Aug 24, 2019
Copy link
Member

left a comment

Thanks, this is looking good for me.

Just a general suggestion: You could consider adding a scripting function $replace_forbidden() for this using register_script_function. This way the user have control to apply the replacement to any tag they want. E.g.

$set(composer,$replace_forbidden(%composer%))

See the keep or videotools plugins for examples

PLUGIN_NAME = "Replace Forbidden Symbols"
PLUGIN_AUTHOR = "Alex Rustler <alex_rustler@rambler.ru>"
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.9", "0.10", "0.11", "0.15", "2.0"]

This comment has been minimized.

Copy link
@phw

phw Aug 24, 2019

Member

You could add 2.2 here as well, that is the version of the next API version in the upcoming release. But your plugin would still run without this, this is just to be on the safe side for the future and to clearly indicate compatibility.

This comment has been minimized.

Copy link
@AlexRustler

AlexRustler Aug 25, 2019

Author Contributor

Hello!
Thanks for review, but I need help for use register_script_function.
When I write this code:
@register_script_function def replace_forbidden(value): return [fix_forbidden(x) for x in value]

and script in Picard:
$set(composer,$replace_forbidden(%composer%))

I got error: replace_forbidden() takes 1positional argumnet but 2 were given.

I try this:
@register_script_function def script_forbidden(parser, value): return replace_forbidden(value)

and script in Picard:
$set(composer,$script_forbidden(%composer%))

and got error: sequence item 0: expected str instance, list found.

I don't understand reason of errors.

This comment has been minimized.

Copy link
@phw

phw Aug 25, 2019

Member

The problem here is that your replace_forbidden expects a list, but tagger script operates on strings. The proper function to wrap would be the fix_forbidden function. I would add something like this:

def script_replace_forbidden(parser, value):
    return fix_forbidden(value)

register_script_function(script_replace_forbidden, name="replace_forbidden")
@zas
zas approved these changes Aug 25, 2019
@phw
phw approved these changes Aug 25, 2019

@zas zas merged commit ffbcb39 into metabrainz:2.0 Aug 26, 2019

2 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.