mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 00:24:25 +01:00
Apply substitute rules in sequence
This commit is contained in:
parent
19eb729db3
commit
8e0558b804
2 changed files with 11 additions and 3 deletions
|
|
@ -34,9 +34,7 @@ class Substitute(BeetsPlugin):
|
|||
"""Do the actual replacing."""
|
||||
if text:
|
||||
for pattern, replacement in self.substitute_rules:
|
||||
new_text, subs_made = pattern.subn(replacement, text)
|
||||
if subs_made > 0:
|
||||
return new_text
|
||||
text = pattern.sub(replacement, text)
|
||||
return text
|
||||
else:
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -78,3 +78,13 @@ class SubstitutePluginTest(PluginTestCase):
|
|||
("b", "y"),
|
||||
],
|
||||
)
|
||||
|
||||
def test_rules_applied_in_sequence(self):
|
||||
self.run_substitute(
|
||||
{"a": "b", "b": "c", "d": "a"},
|
||||
[
|
||||
("a", "c"),
|
||||
("b", "c"),
|
||||
("d", "a"),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue