Skip to content

Commit

Permalink
compile modify templates only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Dec 15, 2021
1 parent a2030d1 commit 795bc2e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from beets import importer
from beets import util
from beets.util import syspath, normpath, ancestry, displayable_path, \
MoveOperation
MoveOperation, functemplate
from beets import library
from beets import config
from beets import logging
Expand Down Expand Up @@ -1420,9 +1420,10 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm):
print_('Modifying {} {}s.'
.format(len(objs), 'album' if album else 'item'))
changed = []
templates = {key: functemplate.template(value) for key, value in mods.items()}
for obj in objs:
obj_mods = {key: model_cls._parse(key, format(obj, value))
for key, value in mods.items()}
obj_mods = {key: model_cls._parse(key, obj.evaluate_template(templates[key]))
for key in mods.keys()}
if print_and_modify(obj, obj_mods, dels) and obj not in changed:
changed.append(obj)

Expand Down

0 comments on commit 795bc2e

Please sign in to comment.