From 6fee2ff1a0d2370bcab68bbde9ea894a8f319fd5 Mon Sep 17 00:00:00 2001
From: Carlin Mangar
Date: Thu, 22 Oct 2009 15:38:38 +1100
Subject: [PATCH] Script.py additions, and some EOL conversions. Also include a
slightly improved build string for betas.
---
picard/__init__.py | 2 +-
picard/script.py | 24 ++++++++++++++++++++++++
resources/img-src/Copyright.htm | 16 ++++++++--------
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/picard/__init__.py b/picard/__init__.py
index 8cf24bdaa..d4b59707b 100644
--- a/picard/__init__.py
+++ b/picard/__init__.py
@@ -25,7 +25,7 @@ if version_info[3] == 'final':
else:
version_string = '%d.%d.%d' % version_info[:3]
else:
- version_string = '%d.%d.%d%s%d' % version_info
+ version_string = '%d.%d.%d_%s%d' % version_info
__version__ = version_string
api_versions = ["0.10.0", "0.11.0", "0.12.0"]
diff --git a/picard/script.py b/picard/script.py
index 5d3e45925..1b11e3949 100644
--- a/picard/script.py
+++ b/picard/script.py
@@ -2,6 +2,9 @@
#
# Picard, the next-generation MusicBrainz tagger
# Copyright (C) 2006-2007 Lukáš Lalinský
+# Copyright (C) 2007 Javier Kohen
+# Copyright (C) 2008 Philipp Wolfer
+#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -18,6 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import re
+import unicodedata
from picard.plugin import ExtensionPoint
class ScriptError(Exception): pass
@@ -460,6 +464,23 @@ def func_matchedtracks(parser, arg):
return str(parser.file.parent.album.get_num_matched_tracks())
return "0"
+def func_firstalphachar(parser, text, nonalpha="#"):
+ if len(text) == 0:
+ return nonalpha
+ firstchar = text[0]
+ if firstchar.isalpha():
+ return firstchar.upper()
+ else:
+ return nonalpha
+
+def func_initials(parser, text):
+ return "".join(a[:1] for a in text.split(" ") if a[:1].isalpha())
+
+def func_trunc(parser, text, length):
+ if len(text) <= length:
+ return text
+ else:
+ return text[:length].rsplit(' ', 1)[0]
register_script_function(func_if, "if", eval_args=False)
register_script_function(func_if2, "if2", eval_args=False)
@@ -497,3 +518,6 @@ register_script_function(func_copy, "copy")
register_script_function(func_len, "len")
register_script_function(func_performer, "performer")
register_script_function(func_matchedtracks, "matchedtracks")
+register_script_function(func_firstalphachar, "firstalphachar")
+register_script_function(func_initials, "initials")
+register_script_function(func_trunc, "trunc")
diff --git a/resources/img-src/Copyright.htm b/resources/img-src/Copyright.htm
index d6cd14192..14fb85264 100644
--- a/resources/img-src/Copyright.htm
+++ b/resources/img-src/Copyright.htm
@@ -1,9 +1,9 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file