Removed unicode_literals from plugins

* echonest
* edit
* embedart
* embyupdate
This commit is contained in:
Peter Kessen 2016-02-20 13:35:54 +01:00
parent 5547a82848
commit 53d2c8d9db
4 changed files with 51 additions and 52 deletions

View file

@ -15,8 +15,7 @@
"""Fetch a variety of acoustic metrics from The Echo Nest.
"""
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from __future__ import (division, absolute_import, print_function)
import time
import socket
@ -465,10 +464,11 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
def commands(self):
fetch_cmd = ui.Subcommand('echonest',
help='fetch metadata from The Echo Nest')
help=u'fetch metadata from The Echo Nest')
fetch_cmd.parser.add_option(
'-f', '--force', dest='force', action='store_true', default=False,
help='(re-)download information from the EchoNest'
u'-f', u'--force', dest='force',
action='store_true', default=False,
help=u'(re-)download information from the EchoNest'
)
def fetch_func(lib, opts, args):
@ -483,10 +483,10 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
fetch_cmd.func = fetch_func
sim_cmd = ui.Subcommand('echosim', help='show related files')
sim_cmd = ui.Subcommand('echosim', help=u'show related files')
sim_cmd.parser.add_option(
'-t', '--threshold', dest='threshold', action='store',
type='float', default=0.15, help='Set difference threshold'
u'-t', u'--threshold', dest='threshold', action='store',
type='float', default=0.15, help=u'Set difference threshold'
)
sim_cmd.parser.add_format_option()

View file

@ -14,8 +14,7 @@
"""Open metadata information in a text editor to let the user edit it.
"""
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from __future__ import (division, absolute_import, print_function)
from beets import plugins
from beets import util
@ -68,7 +67,7 @@ def load(s):
for d in yaml.load_all(s):
if not isinstance(d, dict):
raise ParseError(
'each entry must be a dictionary; found {}'.format(
u'each entry must be a dictionary; found {}'.format(
type(d).__name__
)
)
@ -78,7 +77,7 @@ def load(s):
out.append({unicode(k): v for k, v in d.items()})
except yaml.YAMLError as e:
raise ParseError('invalid YAML: {}'.format(e))
raise ParseError(u'invalid YAML: {}'.format(e))
return out
@ -154,18 +153,18 @@ class EditPlugin(plugins.BeetsPlugin):
def commands(self):
edit_command = ui.Subcommand(
'edit',
help='interactively edit metadata'
help=u'interactively edit metadata'
)
edit_command.parser.add_option(
'-f', '--field',
u'-f', u'--field',
metavar='FIELD',
action='append',
help='edit this field also',
help=u'edit this field also',
)
edit_command.parser.add_option(
'--all',
u'--all',
action='store_true', dest='all',
help='edit all fields',
help=u'edit all fields',
)
edit_command.parser.add_album_option()
edit_command.func = self._edit_command
@ -179,7 +178,7 @@ class EditPlugin(plugins.BeetsPlugin):
items, albums = _do_query(lib, query, opts.album, False)
objs = albums if opts.album else items
if not objs:
ui.print_('Nothing to edit.')
ui.print_(u'Nothing to edit.')
return
# Get the fields to edit.
@ -248,15 +247,15 @@ class EditPlugin(plugins.BeetsPlugin):
with open(new.name) as f:
new_str = f.read()
if new_str == old_str:
ui.print_("No changes; aborting.")
ui.print_(u"No changes; aborting.")
return False
# Parse the updated data.
try:
new_data = load(new_str)
except ParseError as e:
ui.print_("Could not read data: {}".format(e))
if ui.input_yn("Edit again to fix? (Y/n)", True):
ui.print_(u"Could not read data: {}".format(e))
if ui.input_yn(u"Edit again to fix? (Y/n)", True):
continue
else:
return False
@ -267,18 +266,18 @@ class EditPlugin(plugins.BeetsPlugin):
for obj in objs:
changed |= ui.show_model_changes(obj)
if not changed:
ui.print_('No changes to apply.')
ui.print_(u'No changes to apply.')
return False
# Confirm the changes.
choice = ui.input_options(
('continue Editing', 'apply', 'cancel')
(u'continue Editing', u'apply', u'cancel')
)
if choice == 'a': # Apply.
if choice == u'a': # Apply.
return True
elif choice == 'c': # Cancel.
elif choice == u'c': # Cancel.
return False
elif choice == 'e': # Keep editing.
elif choice == u'e': # Keep editing.
# Reset the temporary changes to the objects.
for obj in objs:
obj.read()
@ -296,7 +295,7 @@ class EditPlugin(plugins.BeetsPlugin):
are temporary.
"""
if len(old_data) != len(new_data):
self._log.warn('number of objects changed from {} to {}',
self._log.warn(u'number of objects changed from {} to {}',
len(old_data), len(new_data))
obj_by_id = {o.id: o for o in objs}
@ -307,7 +306,7 @@ class EditPlugin(plugins.BeetsPlugin):
forbidden = False
for key in ignore_fields:
if old_dict.get(key) != new_dict.get(key):
self._log.warn('ignoring object whose {} changed', key)
self._log.warn(u'ignoring object whose {} changed', key)
forbidden = True
break
if forbidden:
@ -322,5 +321,5 @@ class EditPlugin(plugins.BeetsPlugin):
# Save to the database and possibly write tags.
for ob in objs:
if ob._dirty:
self._log.debug('saving changes to {}', ob)
self._log.debug(u'saving changes to {}', ob)
ob.try_sync(ui.should_write(), ui.should_move())

View file

@ -14,8 +14,7 @@
# included in all copies or substantial portions of the Software.
"""Allows beets to embed album art into file metadata."""
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from __future__ import (division, absolute_import, print_function)
import os.path
@ -56,10 +55,10 @@ class EmbedCoverArtPlugin(BeetsPlugin):
def commands(self):
# Embed command.
embed_cmd = ui.Subcommand(
'embedart', help='embed image files into file metadata'
'embedart', help=u'embed image files into file metadata'
)
embed_cmd.parser.add_option(
'-f', '--file', metavar='PATH', help='the image file to embed'
u'-f', u'--file', metavar='PATH', help=u'the image file to embed'
)
maxwidth = self.config['maxwidth'].get(int)
compare_threshold = self.config['compare_threshold'].get(int)
@ -84,17 +83,18 @@ class EmbedCoverArtPlugin(BeetsPlugin):
embed_cmd.func = embed_func
# Extract command.
extract_cmd = ui.Subcommand('extractart',
help='extract an image from file metadata')
extract_cmd.parser.add_option('-o', dest='outpath',
help='image output file')
extract_cmd.parser.add_option('-n', dest='filename',
help='image filename to create for all '
'matched albums')
extract_cmd.parser.add_option('-a', dest='associate',
action='store_true',
help='associate the extracted images '
'with the album')
extract_cmd = ui.Subcommand(
'extractart',
help=u'extract an image from file metadata')
extract_cmd.parser.add_option(
u'-o', dest='outpath',
help=u'image output file')
extract_cmd.parser.add_option(
u'-n', dest='filename',
help=u'image filename to create for all matched albums')
extract_cmd.parser.add_option(
'-a', dest='associate', action='store_true',
help='associate the extracted images with the album')
def extract_func(lib, opts, args):
if opts.outpath:
@ -104,8 +104,8 @@ class EmbedCoverArtPlugin(BeetsPlugin):
filename = bytestring_path(opts.filename or
config['art_filename'].get())
if os.path.dirname(filename) != '':
self._log.error(u"Only specify a name rather than a path "
u"for -n")
self._log.error(
u"Only specify a name rather than a path for -n")
return
for album in lib.albums(decargs(args)):
artpath = normpath(os.path.join(album.path, filename))
@ -117,8 +117,9 @@ class EmbedCoverArtPlugin(BeetsPlugin):
extract_cmd.func = extract_func
# Clear command.
clear_cmd = ui.Subcommand('clearart',
help='remove images from file metadata')
clear_cmd = ui.Subcommand(
'clearart',
help=u'remove images from file metadata')
def clear_func(lib, opts, args):
art.clear(self._log, lib, decargs(args))
@ -142,7 +143,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
"""
if self.config['remove_art_file'] and album.artpath:
if os.path.isfile(album.artpath):
self._log.debug('Removing album art file for {0}', album)
self._log.debug(u'Removing album art file for {0}', album)
os.remove(album.artpath)
album.artpath = None
album.store()

View file

@ -8,8 +8,7 @@
username: user
password: password
"""
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from __future__ import (division, absolute_import, print_function)
from beets import config
from beets.plugins import BeetsPlugin
@ -120,7 +119,7 @@ class EmbyUpdate(BeetsPlugin):
token = get_token(host, port, headers, auth_data)
if not token:
self._log.warning(
u'Couldnt not get token for user {0}'.format(username))
u'Could not get token for user {0}'.format(username))
return
# Recreate headers with a token.