mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 03:52:51 +01:00
Allow unicode in rewrite items
This commit makes rewrite explicitely match items using the .lower() function instead of using Pythons builtin re.I flag. This is required as the re.I flag only allows for case-independent pattern matching with ascii chars. Even worse, the pattern is stored in lowercase when using re.I, but the value to be matched isn't lowercased. Example: [rewrite] artist Сергей Васильевич Рахманинов: Sergei Rachmaninoff
This commit is contained in:
parent
f7040f922c
commit
a0e133ae5d
1 changed files with 2 additions and 2 deletions
|
|
@ -33,7 +33,7 @@ def rewriter(field, rules):
|
|||
def fieldfunc(item):
|
||||
value = getattr(item, field)
|
||||
for pattern, replacement in rules:
|
||||
if pattern.match(value):
|
||||
if pattern.match(value.lower()):
|
||||
# Rewrite activated.
|
||||
return replacement
|
||||
# Not activated; return original value.
|
||||
|
|
@ -59,7 +59,7 @@ class RewritePlugin(BeetsPlugin):
|
|||
raise ui.UserError("invalid field name (%s) in rewriter" %
|
||||
fieldname)
|
||||
log.debug(u'adding template field %s' % key)
|
||||
pattern = re.compile(pattern, re.I)
|
||||
pattern = re.compile(pattern.lower())
|
||||
rules[fieldname].append((pattern, value))
|
||||
if fieldname == 'artist':
|
||||
# Special case for the artist field: apply the same
|
||||
|
|
|
|||
Loading…
Reference in a new issue