mirror of
https://github.com/beetbox/beets.git
synced 2026-01-02 22:12:53 +01:00
_confirmation does not need to be a closure
This commit is contained in:
parent
1fbbcf65fd
commit
c8499eb56d
1 changed files with 27 additions and 23 deletions
|
|
@ -27,6 +27,33 @@ from beets import config
|
|||
from beets import art
|
||||
|
||||
|
||||
def _confirmation(items, opts):
|
||||
"""Show the list of affected objects (items or albums) and confirm
|
||||
that the user wants to modify their artwork.
|
||||
"""
|
||||
# Confirm artwork changes to library items.
|
||||
if not opts.yes:
|
||||
# Prepare confirmation with user.
|
||||
print_()
|
||||
|
||||
fmt = u'$albumartist - $album'
|
||||
istr = u'album'
|
||||
if opts.file:
|
||||
fmt = u'$albumartist - $album - $title'
|
||||
istr = u'file'
|
||||
prompt = u'Modify artwork for %i %s%s (y/n)?' % \
|
||||
(len(items), istr, 's' if len(items) > 1 else '')
|
||||
|
||||
# Show all the items.
|
||||
for item in items:
|
||||
print_(format(item, fmt))
|
||||
|
||||
# Confirm with user.
|
||||
if not ui.input_yn(prompt, True):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class EmbedCoverArtPlugin(BeetsPlugin):
|
||||
"""Allows albumart to be embedded into the actual files.
|
||||
"""
|
||||
|
|
@ -67,29 +94,6 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
compare_threshold = self.config['compare_threshold'].get(int)
|
||||
ifempty = self.config['ifempty'].get(bool)
|
||||
|
||||
def _confirmation(items, opts):
|
||||
# Confirm artwork changes to library items.
|
||||
if not opts.yes:
|
||||
# Prepare confirmation with user.
|
||||
print_()
|
||||
|
||||
fmt = u'$albumartist - $album'
|
||||
istr = u'album'
|
||||
if opts.file:
|
||||
fmt = u'$albumartist - $album - $title'
|
||||
istr = u'file'
|
||||
prompt = u'Modify artwork for %i %s%s (y/n)?' % \
|
||||
(len(items), istr, 's' if len(items) > 1 else '')
|
||||
|
||||
# Show all the items.
|
||||
for item in items:
|
||||
print_(format(item, fmt))
|
||||
|
||||
# Confirm with user.
|
||||
if not ui.input_yn(prompt, True):
|
||||
return False
|
||||
return True
|
||||
|
||||
def embed_func(lib, opts, args):
|
||||
if opts.file:
|
||||
imagepath = normpath(opts.file)
|
||||
|
|
|
|||
Loading…
Reference in a new issue