mirror of
https://github.com/beetbox/beets.git
synced 2026-01-14 04:01:43 +01:00
Use ui.should_write everywhere
There sure are a lot of plugins that want to write metadata!
This commit is contained in:
parent
5b761f029e
commit
9f7aa866bd
10 changed files with 13 additions and 20 deletions
|
|
@ -149,7 +149,7 @@ def _bool_fallback(opt, view):
|
|||
return opt
|
||||
|
||||
|
||||
def should_write(write_opt):
|
||||
def should_write(write_opt=None):
|
||||
"""Decide whether a command that updates metadata should also write tags,
|
||||
using the importer configuration as the default.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -194,8 +194,7 @@ class AcoustidPlugin(plugins.BeetsPlugin):
|
|||
|
||||
def fingerprint_cmd_func(lib, opts, args):
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
fingerprint_item(self._log, item,
|
||||
write=config['import']['write'].get(bool))
|
||||
fingerprint_item(self._log, item, write=ui.should_write())
|
||||
fingerprint_cmd.func = fingerprint_cmd_func
|
||||
|
||||
return [submit_cmd, fingerprint_cmd]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import tempfile
|
|||
from string import Template
|
||||
import subprocess
|
||||
|
||||
from beets import util, config, plugins, ui
|
||||
from beets import util, plugins, ui
|
||||
from beets.dbcore import types
|
||||
import pyechonest
|
||||
import pyechonest.song
|
||||
|
|
@ -472,7 +472,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
|
||||
def fetch_func(lib, opts, args):
|
||||
self.config.set_args(opts)
|
||||
write = config['import']['write'].get(bool)
|
||||
write = ui.should_write()
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
self._log.info(u'{0}', item)
|
||||
if self.config['force'] or self.requires_update(item):
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
def process_album(self, album):
|
||||
"""Automatically embed art after art has been set
|
||||
"""
|
||||
if self.config['auto'] and config['import']['write']:
|
||||
if self.config['auto'] and ui.should_write():
|
||||
max_width = self.config['maxwidth'].get(int)
|
||||
art.embed_album(self._log, album, max_width, True,
|
||||
self.config['compare_threshold'].get(int),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import re
|
|||
from beets import plugins
|
||||
from beets import ui
|
||||
from beets.util import displayable_path
|
||||
from beets import config
|
||||
|
||||
|
||||
def split_on_feat(artist):
|
||||
|
|
@ -102,7 +101,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
|||
def func(lib, opts, args):
|
||||
self.config.set_args(opts)
|
||||
drop_feat = self.config['drop'].get(bool)
|
||||
write = config['import']['write'].get(bool)
|
||||
write = ui.should_write()
|
||||
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
self.ft_in_title(item, drop_feat)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import subprocess
|
|||
from beets import ui
|
||||
from beets import util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets import config
|
||||
|
||||
|
||||
class KeyFinderPlugin(BeetsPlugin):
|
||||
|
|
@ -46,8 +45,7 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
return [cmd]
|
||||
|
||||
def command(self, lib, opts, args):
|
||||
self.find_key(lib.items(ui.decargs(args)),
|
||||
write=config['import']['write'].get(bool))
|
||||
self.find_key(lib.items(ui.decargs(args)), write=ui.should_write())
|
||||
|
||||
def imported(self, session, task):
|
||||
self.find_key(task.items)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import traceback
|
|||
from beets import plugins
|
||||
from beets import ui
|
||||
from beets.util import normpath, plurality
|
||||
from beets import config
|
||||
from beets import library
|
||||
|
||||
|
||||
|
|
@ -336,7 +335,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
)
|
||||
|
||||
def lastgenre_func(lib, opts, args):
|
||||
write = config['import']['write'].get(bool)
|
||||
write = ui.should_write()
|
||||
self.config.set_args(opts)
|
||||
|
||||
for album in lib.albums(ui.decargs(args)):
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import warnings
|
|||
from HTMLParser import HTMLParseError
|
||||
|
||||
from beets import plugins
|
||||
from beets import config, ui
|
||||
from beets import ui
|
||||
|
||||
|
||||
DIV_RE = re.compile(r'<(/?)div>?', re.I)
|
||||
|
|
@ -557,7 +557,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
def func(lib, opts, args):
|
||||
# The "write to files" option corresponds to the
|
||||
# import_write config value.
|
||||
write = config['import']['write'].get(bool)
|
||||
write = ui.should_write()
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
self.fetch_item_lyrics(
|
||||
lib, item, write,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from __future__ import (division, absolute_import, print_function,
|
|||
from beets.plugins import BeetsPlugin
|
||||
from beets import autotag, library, ui, util
|
||||
from beets.autotag import hooks
|
||||
from beets import config
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
|
|
@ -50,7 +49,7 @@ class MBSyncPlugin(BeetsPlugin):
|
|||
default=True, dest='move',
|
||||
help="don't move files in library")
|
||||
cmd.parser.add_option('-W', '--nowrite', action='store_false',
|
||||
default=config['import']['write'], dest='write',
|
||||
default=None, dest='write',
|
||||
help="don't write updated metadata to files")
|
||||
cmd.parser.add_format_option()
|
||||
cmd.func = self.func
|
||||
|
|
@ -61,7 +60,7 @@ class MBSyncPlugin(BeetsPlugin):
|
|||
"""
|
||||
move = opts.move
|
||||
pretend = opts.pretend
|
||||
write = opts.write
|
||||
write = ui.should_write(opts.write)
|
||||
query = ui.decargs(args)
|
||||
|
||||
self.singletons(lib, query, move, pretend, write)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ from beets import logging
|
|||
from beets import ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.util import syspath, command_output, displayable_path
|
||||
from beets import config
|
||||
|
||||
|
||||
# Utilities.
|
||||
|
|
@ -926,7 +925,7 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
def func(lib, opts, args):
|
||||
self._log.setLevel(logging.INFO)
|
||||
|
||||
write = config['import']['write'].get(bool)
|
||||
write = ui.should_write()
|
||||
|
||||
if opts.album:
|
||||
for album in lib.albums(ui.decargs(args)):
|
||||
|
|
|
|||
Loading…
Reference in a new issue