Skip to content

Commit

Permalink
Integrate a couple more plugins ...
Browse files Browse the repository at this point in the history
eq2 and ne2 by Brian Schweitzer.
  • Loading branch information
Sophist-UK committed Apr 18, 2014
1 parent eebf7f4 commit 2a0c939
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions picard/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ def func_swapprefix(parser, text, *prefixes):
Moves the specified prefixes to the end of text.
If no prefix is specified 'A' and 'The' are taken
as default.
Integrated from the swapprefix plugin by Philipp Wolfer.
"""
if not prefixes:
prefixes = ('A', 'The')
Expand All @@ -655,6 +656,7 @@ def func_delprefix(parser, text, *prefixes):
Deletes the specified prefixes.
If no prefix is specified 'A' and 'The' are taken
as default.
Modified by Sophist from the swapprefix plugin by Philipp Wolfer.
"""
if not prefixes:
prefixes = ('A', 'The')
Expand All @@ -668,6 +670,28 @@ def func_delprefix(parser, text, *prefixes):
return text


def func_eq2(parser, x, *args):
"""
Compare a variable against more than one string.
Example: $if($eq2(%artist%,foo,bar,baz),$set(engineer,test))
Integrated from the eq2 plugin by Brian Schweitzer.
"""
for i in (i for i in args if i == x):
return "1"
return ''


def func_ne2(parser, x, *args):
"""
Compare a variable against more than one string.
Example: $if($ne2(%artist%,foo,bar,baz),$set(engineer,test))
Integrated from the ne2 plugin by Brian Schweitzer.
"""
for i in (i for i in args if i == x):
return ""
return "1"


register_script_function(func_if, "if", eval_args=False)
register_script_function(func_if2, "if2", eval_args=False)
register_script_function(func_noop, "noop", eval_args=False)
Expand Down Expand Up @@ -713,3 +737,5 @@ def func_delprefix(parser, text, *prefixes):
register_script_function(func_truncate, "truncate")
register_script_function(func_swapprefix, "swapprefix")
register_script_function(func_delprefix, "delprefix")
register_script_function(func_eq2, "eq2")
register_script_function(func_ne2, "ne2")

0 comments on commit 2a0c939

Please sign in to comment.