mirror of
https://github.com/beetbox/beets.git
synced 2026-01-31 04:21:42 +01:00
Merge pull request #44 from calmh/unicode-replace
Handle unicode in replacement config
This commit is contained in:
commit
321ea2bfef
2 changed files with 10 additions and 1 deletions
|
|
@ -460,7 +460,8 @@ def _get_replacements(config):
|
|||
repl_string = config_val(config, 'beets', 'replace', None)
|
||||
if not repl_string:
|
||||
return
|
||||
repl_string = repl_string.decode('utf8')
|
||||
if not isinstance(repl_string, unicode):
|
||||
repl_string = repl_string.decode('utf8')
|
||||
|
||||
parts = repl_string.strip().split()
|
||||
if not parts:
|
||||
|
|
|
|||
|
|
@ -547,6 +547,14 @@ class ConfigTest(unittest.TestCase):
|
|||
[beets]
|
||||
replace=[xy] z"""), func)
|
||||
|
||||
def test_replacements_parsed_unicode(self):
|
||||
def func(lib, config, opts, args):
|
||||
replacements = lib.replacements
|
||||
self.assertEqual(replacements, [(re.compile(ur'\u2019'), u'z')])
|
||||
self._run_main([], textwrap.dedent(u"""
|
||||
[beets]
|
||||
replace=\u2019 z"""), func)
|
||||
|
||||
def test_empty_replacements_produce_none(self):
|
||||
def func(lib, config, opts, args):
|
||||
replacements = lib.replacements
|
||||
|
|
|
|||
Loading…
Reference in a new issue