Topic: 2 new plugins released - $p() and $eq2()

I've released two new plugins on the plugins page.  Both add taggerscript functions.

The first is $eq2().  It works like $eq(), but for more than a single test string: $eq(string to test against, test string 1, test string 2, .. test string n).  %variables% can also be used, rather than predefined strings.  Any number of test strings can be used.

The second is $p().  It works like a reverse \p{Foo} Unicode Property regex test.  Give it a string, and it returns the Unicode Property (ie, the script) of the first character of that string.  Useage: $p(any string or %variable%)

Examples:
"Anything" -> latin, "Аракс" or "Эдуард" -> cyrillic, "मुकेश" -> devanagari, "つしまみれ" -> hiragana, etc.

$p() is a little slow, for the first release loaded, because it has to initialize the various regexes used, but for every other release loaded afterwards, it reuses those regexes, so it's far faster than that first one.

$p() also supports a second argument, "True" (correct capitalization is important here).  By default, $p() only checks scripts officially within Unicode.  If the second argument is set to True, then it will also check user-defined code points for scripts not officially within Unicode.  Currently, this only means that ConScript scripts are checked, but in future I'll also be adding in new scripts and characters added to already official scripts which are on the Unicode roadmap, but not yet officially within Unicode itself.  (If there's any others that'd be worth checking, let me know; Omiglot's scripts don't seem to be in sufficient widespread use to be worth adding, but I'd be willing to add any of those, one-off, if there's a need for it.)

The only official "script" that $p() doesn't check for is the "common" script.  These are pretty much all punctuation and control characters anyhow, and there's so many of them, it really slows down the plugin to check for them.  Instead, $p() will return "common or unknown" if no script is matched, rather than actually checking for common and differentiating "common" or "unknown" (which would be the 'correct' implementation per Unicode's guidance).

$p() is especially useful if you're using a 'first character of artist name/artist name/...' type of naming string, but only want that to be done for characters of 1+ specific scripts.  For example, my music dir currently has:
A/...
B/...
C/...
...
Z/...
[common or unknown]/...  (most of this will eventually end up in [symbols & punctuation] after I add some missing punctuation marks to that separate test)
[cyrillic]/..
[devanagari]/..
[greek]/..
[han]/..
[hangul]/..
[hiragana]/..
[katakana]/..
[number]/..  (separately separated by a $in(0123456789,%string%) test after the $p() test)
[symbols & punctuation]/.. (separately separated by a $in('[*…\(\$+-:",%string%) test after the $p() test)

Much more readable and functional to me than having ザ/..., コ/..., 윤/..., etc.

The links are on http://wiki.musicbrainz.org/Picard_Plugins , or directly, $eq2() http://rapidshare.com/files/452223583/eq2.py.zip and $p() http://rapidshare.com/files/453111881/p.py.zip

Brian

PS: I'm also tweaking a $ne2() and $in2(), along the same lines of $eq2().  When they're tested and ready, they'll also be added to the plugins page.

You stumble onto 50 berserkers!

Re: 2 new plugins released - $p() and $eq2()

The eq2 rapidshare link is broken: "Unassigned file limit of 10 downloads reached." Can you use a different host?

Re: 2 new plugins released - $p() and $eq2()

Sure, try this one: http://hotfile.com/dl/110973002/707187f … s.zip.html

That includes $p(), $eq2(), as well as a $ne2().  $ne2() isn't as tested, but it's been functioning without issues for me since I started testing it yesterday.

You stumble onto 50 berserkers!

Re: 2 new plugins released - $p() and $eq2()

Thanks. :) I mainly wanted eq2, and it works nicely.

Re: 2 new plugins released - $p() and $eq2()

Here's a test $in2() as well.  :)

http://hotfile.com/dl/111073105/173b6ae/in2.py.zip.html

You stumble onto 50 berserkers!

Re: 2 new plugins released - $p() and $eq2()

When I try to change to API version to include "0.15" $eq2() and $ne2() work but I get errors for the $p() plugin as follows:

E: <sip.voidptr object at 0x01173128> 12:10:29 Traceback (most recent call last):
  File "picard\plugin.pyo", line 138, in load
  File "C:\Documents and Settings\Administrator.MARKS-TOWER-II.001\Application Data\MusicBrainz\Picard\plugins\p.py", line 37, in <module>
  File "re.pyo", line 190, in compile
  File "re.pyo", line 245, in _compile
error: bad character range

I was just wondering if anyone was looking at updating this plugin to work with the current version.

Thanks

Re: 2 new plugins released - $p() and $eq2()

I just updated to the latest beta yesterday myself.  I've not had the time yet to do anything to update the various plugins other than updating the version numbers.  However, while I am seeing a different issue in one of the plugins (I've not yet checked into which one it is), I'm not seeing this particular bug.  I'll put a note in here when I do get all the plugins fully updated.

That said, my Python isn't stellar, but looking at that snippet, I'm a bit puzzled as to what .py file re.pyo is from.  I presume it's generated from re.py - but there is no re.py associated with any of my plugins.  I have most other people's installed as well, but none uses that file name either.  Any other info you can provide me?

Again, I'm not seeing that particular issue in the p.py I've updated the version number in; just in case, this should be that particular line of p.py to make Picard at least think it's compatible with .15beta2:
PLUGIN_API_VERSIONS = ["0.12", "0.13", "0.14", "0.15"]

Thanks,
Brian

You stumble onto 50 berserkers!

Re: 2 new plugins released - $p() and $eq2()

In case anyone's looking, I've updated $p, $eq2, and $ne2, as well as all the search plugins.  The new versions can all be found at https://github.com/brianfreud/Picard-plugins .  If anyone has a copy of $in2, please let me know? 

Thanks,
Brian

You stumble onto 50 berserkers!

Re: 2 new plugins released - $p() and $eq2()

I'm having trouble using $ne2 with Picard 1.0 on a Mac.

The error I get is...

Wrong number of arguments for $ne2: Expected 1, got 4 at position 108, line 21

Obviously $ne2 should be able to take more than one argument.  Anyone else seeing this problem?

Re: 2 new plugins released - $p() and $eq2()

The problem is quite simple: since Picard 1.0 the number of arguments passed to a scripting function is compared to the actual number of arguments that function expects to get - $eq2 and $ne2 however take an undefined (well, at least one) argument, so that check has to be disabled for them by using

register_script_function(func_name, "name", check_argcount=False)