introduced print_modify_item as seperate function

preparation to implement interactive selection in modify command
This commit is contained in:
Peter Kessen 2016-01-28 21:49:33 +01:00
parent 7bdc7d37d3
commit 6b39751337

View file

@ -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