From 795bc2efc112fdab874b903b48facddeceb4ee2a Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Wed, 15 Dec 2021 14:31:15 +0100 Subject: [PATCH] compile modify templates only once --- beets/ui/commands.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 27ec17f5be..623341b42a 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -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 @@ -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)