Update beets to 1.4.7

Also updates:
- colorama-0.4.1
- jellyfish-0.6.1
- munkres-1.0.12
- musicbrainzngs-0.6
- mutagen-1.41.1
- pyyaml-3.13
- six-1.12.0
- unidecode-1.0.23
This commit is contained in:
Labrys of Knossos 2018-12-15 00:52:11 -05:00
parent 05b0fb498f
commit e854005ae1
193 changed files with 15896 additions and 6384 deletions

View file

@ -20,9 +20,11 @@ from __future__ import division, absolute_import, print_function
import shlex
from beets.plugins import BeetsPlugin
from beets.ui import decargs, print_, vararg_callback, Subcommand, UserError
from beets.util import command_output, displayable_path, subprocess
from beets.ui import decargs, print_, Subcommand, UserError
from beets.util import command_output, displayable_path, subprocess, \
bytestring_path, MoveOperation
from beets.library import Item, Album
import six
PLUGIN = 'duplicates'
@ -79,10 +81,9 @@ class DuplicatesPlugin(BeetsPlugin):
help=u'report duplicates only if all attributes are set',
)
self._command.parser.add_option(
u'-k', u'--keys', dest='keys',
action='callback', metavar='KEY1 KEY2',
callback=vararg_callback,
help=u'report duplicates based on keys',
u'-k', u'--key', dest='keys',
action='append', metavar='KEY',
help=u'report duplicates based on keys (use multiple times)',
)
self._command.parser.add_option(
u'-M', u'--merge', dest='merge',
@ -112,14 +113,14 @@ class DuplicatesPlugin(BeetsPlugin):
self.config.set_args(opts)
album = self.config['album'].get(bool)
checksum = self.config['checksum'].get(str)
copy = self.config['copy'].get(str)
copy = bytestring_path(self.config['copy'].as_str())
count = self.config['count'].get(bool)
delete = self.config['delete'].get(bool)
fmt = self.config['format'].get(str)
full = self.config['full'].get(bool)
keys = self.config['keys'].get(list)
keys = self.config['keys'].as_str_seq()
merge = self.config['merge'].get(bool)
move = self.config['move'].get(str)
move = bytestring_path(self.config['move'].as_str())
path = self.config['path'].get(bool)
tiebreak = self.config['tiebreak'].get(dict)
strict = self.config['strict'].get(bool)
@ -135,15 +136,15 @@ class DuplicatesPlugin(BeetsPlugin):
items = lib.items(decargs(args))
if path:
fmt = '$path'
fmt = u'$path'
# Default format string for count mode.
if count and not fmt:
if album:
fmt = '$albumartist - $album'
fmt = u'$albumartist - $album'
else:
fmt = '$albumartist - $album - $title'
fmt += ': {0}'
fmt = u'$albumartist - $album - $title'
fmt += u': {0}'
if checksum:
for i in items:
@ -169,22 +170,22 @@ class DuplicatesPlugin(BeetsPlugin):
return [self._command]
def _process_item(self, item, copy=False, move=False, delete=False,
tag=False, fmt=''):
tag=False, fmt=u''):
"""Process Item `item`.
"""
print_(format(item, fmt))
if copy:
item.move(basedir=copy, copy=True)
item.move(basedir=copy, operation=MoveOperation.COPY)
item.store()
if move:
item.move(basedir=move, copy=False)
item.move(basedir=move)
item.store()
if delete:
item.remove(delete=True)
if tag:
try:
k, v = tag.split('=')
except:
except Exception:
raise UserError(
u"{}: can't parse k=v tag: {}".format(PLUGIN, tag)
)
@ -252,20 +253,19 @@ class DuplicatesPlugin(BeetsPlugin):
"completeness" (objects with more non-null fields come first)
and Albums are ordered by their track count.
"""
if tiebreak:
kind = 'items' if all(isinstance(o, Item)
for o in objs) else 'albums'
kind = 'items' if all(isinstance(o, Item) for o in objs) else 'albums'
if tiebreak and kind in tiebreak.keys():
key = lambda x: tuple(getattr(x, k) for k in tiebreak[kind])
else:
kind = Item if all(isinstance(o, Item) for o in objs) else Album
if kind is Item:
if kind == 'items':
def truthy(v):
# Avoid a Unicode warning by avoiding comparison
# between a bytes object and the empty Unicode
# string ''.
return v is not None and \
(v != '' if isinstance(v, unicode) else True)
fields = kind.all_keys()
(v != '' if isinstance(v, six.text_type) else True)
fields = Item.all_keys()
key = lambda x: sum(1 for f in fields if truthy(getattr(x, f)))
else:
key = lambda x: len(x.items())
@ -311,7 +311,7 @@ class DuplicatesPlugin(BeetsPlugin):
objs[0],
displayable_path(o.path),
displayable_path(missing.destination()))
missing.move(copy=True)
missing.move(operation=MoveOperation.COPY)
return objs
def _merge(self, objs):
@ -329,7 +329,7 @@ class DuplicatesPlugin(BeetsPlugin):
"""Generate triples of keys, duplicate counts, and constituent objects.
"""
offset = 0 if full else 1
for k, objs in self._group_by(objs, keys, strict).iteritems():
for k, objs in self._group_by(objs, keys, strict).items():
if len(objs) > 1:
objs = self._order(objs, tiebreak)
if merge: