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
commit e854005ae1
193 changed files with 15896 additions and 6384 deletions

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2016
#
@ -22,11 +23,12 @@ from beets import ui
from beets.dbcore import types
from beets.importer import action
from beets.ui.commands import _do_query, PromptChoice
from copy import deepcopy
import codecs
import subprocess
import yaml
from tempfile import NamedTemporaryFile
import os
import six
# These "safe" types can avoid the format/parse cycle that most fields go
@ -82,7 +84,7 @@ def load(s):
# Convert all keys to strings. They started out as strings,
# but the user may have inadvertently messed this up.
out.append({unicode(k): v for k, v in d.items()})
out.append({six.text_type(k): v for k, v in d.items()})
except yaml.YAMLError as e:
raise ParseError(u'invalid YAML: {}'.format(e))
@ -141,7 +143,7 @@ def apply_(obj, data):
else:
# Either the field was stringified originally or the user changed
# it from a safe type to an unsafe one. Parse it as a string.
obj.set_parse(key, unicode(value))
obj.set_parse(key, six.text_type(value))
class EditPlugin(plugins.BeetsPlugin):
@ -242,9 +244,15 @@ class EditPlugin(plugins.BeetsPlugin):
old_data = [flatten(o, fields) for o in objs]
# Set up a temporary file with the initial data for editing.
new = NamedTemporaryFile(suffix='.yaml', delete=False)
if six.PY2:
new = NamedTemporaryFile(mode='w', suffix='.yaml', delete=False)
else:
new = NamedTemporaryFile(mode='w', suffix='.yaml', delete=False,
encoding='utf-8')
old_str = dump(old_data)
new.write(old_str)
if six.PY2:
old_str = old_str.decode('utf-8')
new.close()
# Loop until we have parseable data and the user confirms.
@ -255,7 +263,7 @@ class EditPlugin(plugins.BeetsPlugin):
# Read the data back after editing and check whether anything
# changed.
with open(new.name) as f:
with codecs.open(new.name, encoding='utf-8') as f:
new_str = f.read()
if new_str == old_str:
ui.print_(u"No changes; aborting.")
@ -274,7 +282,7 @@ class EditPlugin(plugins.BeetsPlugin):
# Show the changes.
# If the objects are not on the DB yet, we need a copy of their
# original state for show_model_changes.
objs_old = [deepcopy(obj) if not obj._db else None
objs_old = [obj.copy() if obj.id < 0 else None
for obj in objs]
self.apply_data(objs, old_data, new_data)
changed = False
@ -293,9 +301,13 @@ class EditPlugin(plugins.BeetsPlugin):
elif choice == u'c': # Cancel.
return False
elif choice == u'e': # Keep editing.
# Reset the temporary changes to the objects.
# Reset the temporary changes to the objects. I we have a
# copy from above, use that, else reload from the database.
objs = [(old_obj or obj)
for old_obj, obj in zip(objs_old, objs)]
for obj in objs:
obj.read()
if not obj.id < 0:
obj.load()
continue
# Remove the temporary file before returning.
@ -310,8 +322,8 @@ class EditPlugin(plugins.BeetsPlugin):
are temporary.
"""
if len(old_data) != len(new_data):
self._log.warn(u'number of objects changed from {} to {}',
len(old_data), len(new_data))
self._log.warning(u'number of objects changed from {} to {}',
len(old_data), len(new_data))
obj_by_id = {o.id: o for o in objs}
ignore_fields = self.config['ignore_fields'].as_str_seq()
@ -321,7 +333,7 @@ class EditPlugin(plugins.BeetsPlugin):
forbidden = False
for key in ignore_fields:
if old_dict.get(key) != new_dict.get(key):
self._log.warn(u'ignoring object whose {} changed', key)
self._log.warning(u'ignoring object whose {} changed', key)
forbidden = True
break
if forbidden:
@ -356,9 +368,13 @@ class EditPlugin(plugins.BeetsPlugin):
"""Callback for invoking the functionality during an interactive
import session on the *original* item tags.
"""
# Assign temporary ids to the Items.
for i, obj in enumerate(task.items):
obj.id = i + 1
# Assign negative temporary ids to Items that are not in the database
# yet. By using negative values, no clash with items in the database
# can occur.
for i, obj in enumerate(task.items, start=1):
# The importer may set the id to None when re-importing albums.
if not obj._db or obj.id is None:
obj.id = -i
# Present the YAML to the user and let her change it.
fields = self._get_fields(album=False, extra=[])
@ -366,7 +382,8 @@ class EditPlugin(plugins.BeetsPlugin):
# Remove temporary ids.
for obj in task.items:
obj.id = None
if obj.id < 0:
obj.id = None
# Save the new data.
if success: