From 6b3975133706c06c1dd91023af7323dea508e898 Mon Sep 17 00:00:00 2001
From: Peter Kessen
Date: Thu, 28 Jan 2016 21:49:33 +0100
Subject: [PATCH] introduced print_modify_item as seperate function
preparation to implement interactive selection in modify command
---
beets/ui/commands.py | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/beets/ui/commands.py b/beets/ui/commands.py
index 3e3acb7c3..176cf9218 100644
--- a/beets/ui/commands.py
+++ b/beets/ui/commands.py
@@ -1330,13 +1330,7 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm):
.format(len(objs), 'album' if album else 'item'))
changed = set()
for obj in objs:
- obj.update(mods)
- for field in dels:
- try:
- del obj[field]
- except KeyError:
- pass
- if ui.show_model_changes(obj):
+ if print_modify_item(obj, mods, dels):
changed.add(obj)
# Still something to do?
@@ -1364,6 +1358,21 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm):
obj.try_sync(write, move)
+def print_modify_item(obj, mods, dels):
+ """Print the modifications to an item
+ and return False if no changes were made
+ mods: modifications
+ dels: fields to delete
+ """
+ obj.update(mods)
+ for field in dels:
+ try:
+ del obj[field]
+ except KeyError:
+ pass
+ return ui.show_model_changes(obj)
+
+
def modify_parse_args(args):
"""Split the arguments for the modify subcommand into query parts,
assignments (field=value), and deletions (field!). Returns the result as