From 40900aa1cb61de5ab8aae9bf0d584da48b325cb6 Mon Sep 17 00:00:00 2001
From: Peter Kessen
Date: Sat, 20 Feb 2016 12:10:01 +0100
Subject: [PATCH] Removed unicode_literals from plugins
* bucket
* chroma
* convert
* discogs
---
beetsplug/bucket.py | 19 +++++++++----------
beetsplug/chroma.py | 9 ++++-----
beetsplug/convert.py | 23 +++++++++++------------
beetsplug/discogs.py | 23 +++++++++++------------
4 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/beetsplug/bucket.py b/beetsplug/bucket.py
index 7ddc90920..b847cf03c 100644
--- a/beetsplug/bucket.py
+++ b/beetsplug/bucket.py
@@ -16,8 +16,7 @@
"""Provides the %bucket{} function for path formatting.
"""
-from __future__ import (division, absolute_import, print_function,
- unicode_literals)
+from __future__ import (division, absolute_import, print_function)
from datetime import datetime
import re
@@ -46,7 +45,7 @@ def span_from_str(span_str):
"""Convert string to a 4 digits year
"""
if yearfrom < 100:
- raise BucketError("%d must be expressed on 4 digits" % yearfrom)
+ raise BucketError(u"%d must be expressed on 4 digits" % yearfrom)
# if two digits only, pick closest year that ends by these two
# digits starting from yearfrom
@@ -59,12 +58,12 @@ def span_from_str(span_str):
years = [int(x) for x in re.findall('\d+', span_str)]
if not years:
- raise ui.UserError("invalid range defined for year bucket '%s': no "
- "year found" % span_str)
+ raise ui.UserError(u"invalid range defined for year bucket '%s': no "
+ u"year found" % span_str)
try:
years = [normalize_year(x, years[0]) for x in years]
except BucketError as exc:
- raise ui.UserError("invalid range defined for year bucket '%s': %s" %
+ raise ui.UserError(u"invalid range defined for year bucket '%s': %s" %
(span_str, exc))
res = {'from': years[0], 'str': span_str}
@@ -119,8 +118,8 @@ def build_year_spans(year_spans_str):
def str2fmt(s):
"""Deduces formatting syntax from a span string.
"""
- regex = re.compile("(?P\D*)(?P\d+)(?P\D*)"
- "(?P\d*)(?P\D*)")
+ regex = re.compile(r"(?P\D*)(?P\d+)(?P\D*)"
+ r"(?P\d*)(?P\D*)")
m = re.match(regex, s)
res = {'fromnchars': len(m.group('fromyear')),
@@ -166,8 +165,8 @@ def build_alpha_spans(alpha_spans_str, alpha_regexs):
beginIdx = ASCII_DIGITS.index(bucket[0])
endIdx = ASCII_DIGITS.index(bucket[-1])
else:
- raise ui.UserError("invalid range defined for alpha bucket "
- "'%s': no alphanumeric character found" %
+ raise ui.UserError(u"invalid range defined for alpha bucket "
+ u"'%s': no alphanumeric character found" %
elem)
spans.append(
re.compile(
diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py
index cb0eaf24a..e40b2d29f 100644
--- a/beetsplug/chroma.py
+++ b/beetsplug/chroma.py
@@ -16,8 +16,7 @@
"""Adds Chromaprint/Acoustid acoustic fingerprinting support to the
autotagger. Requires the pyacoustid library.
"""
-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 ui
@@ -178,19 +177,19 @@ class AcoustidPlugin(plugins.BeetsPlugin):
def commands(self):
submit_cmd = ui.Subcommand('submit',
- help='submit Acoustid fingerprints')
+ help=u'submit Acoustid fingerprints')
def submit_cmd_func(lib, opts, args):
try:
apikey = config['acoustid']['apikey'].get(unicode)
except confit.NotFoundError:
- raise ui.UserError('no Acoustid user API key provided')
+ raise ui.UserError(u'no Acoustid user API key provided')
submit_items(self._log, apikey, lib.items(ui.decargs(args)))
submit_cmd.func = submit_cmd_func
fingerprint_cmd = ui.Subcommand(
'fingerprint',
- help='generate fingerprints for items without them'
+ help=u'generate fingerprints for items without them'
)
def fingerprint_cmd_func(lib, opts, args):
diff --git a/beetsplug/convert.py b/beetsplug/convert.py
index 6145fdb74..0329f2a52 100644
--- a/beetsplug/convert.py
+++ b/beetsplug/convert.py
@@ -15,8 +15,7 @@
"""Converts tracks or albums to external directory
"""
-from __future__ import (division, absolute_import, print_function,
- unicode_literals)
+from __future__ import (division, absolute_import, print_function)
import os
import threading
@@ -138,21 +137,21 @@ class ConvertPlugin(BeetsPlugin):
self.register_listener('import_task_files', self._cleanup)
def commands(self):
- cmd = ui.Subcommand('convert', help='convert to external location')
+ cmd = ui.Subcommand('convert', help=u'convert to external location')
cmd.parser.add_option('-p', '--pretend', action='store_true',
- help='show actions but do nothing')
+ help=u'show actions but do nothing')
cmd.parser.add_option('-t', '--threads', action='store', type='int',
- help='change the number of threads, \
+ help=u'change the number of threads, \
defaults to maximum available processors')
cmd.parser.add_option('-k', '--keep-new', action='store_true',
- dest='keep_new', help='keep only the converted \
+ dest='keep_new', help=u'keep only the converted \
and move the old files')
cmd.parser.add_option('-d', '--dest', action='store',
- help='set the destination directory')
+ help=u'set the destination directory')
cmd.parser.add_option('-f', '--format', action='store', dest='format',
- help='set the target format of the tracks')
+ help=u'set the target format of the tracks')
cmd.parser.add_option('-y', '--yes', action='store_true', dest='yes',
- help='do not ask for confirmation')
+ help=u'do not ask for confirmation')
cmd.parser.add_album_option()
cmd.func = self.convert_func
return [cmd]
@@ -292,7 +291,7 @@ class ConvertPlugin(BeetsPlugin):
if self.config['embed']:
album = item.get_album()
if album and album.artpath:
- self._log.debug('embedding album art from {}',
+ self._log.debug(u'embedding album art from {}',
util.displayable_path(album.artpath))
art.embed_item(self._log, item, album.artpath,
itempath=converted)
@@ -349,7 +348,7 @@ class ConvertPlugin(BeetsPlugin):
if not opts.dest:
opts.dest = self.config['dest'].get()
if not opts.dest:
- raise ui.UserError('no convert destination set')
+ raise ui.UserError(u'no convert destination set')
opts.dest = util.bytestring_path(opts.dest)
if not opts.threads:
@@ -369,7 +368,7 @@ class ConvertPlugin(BeetsPlugin):
if not pretend:
ui.commands.list_items(lib, ui.decargs(args), opts.album)
- if not (opts.yes or ui.input_yn("Convert? (Y/n)")):
+ if not (opts.yes or ui.input_yn(u"Convert? (Y/n)")):
return
if opts.album:
diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py
index 321fbd09e..26c567a2c 100644
--- a/beetsplug/discogs.py
+++ b/beetsplug/discogs.py
@@ -16,8 +16,7 @@
"""Adds Discogs album search support to the autotagger. Requires the
discogs-client library.
"""
-from __future__ import (division, absolute_import, print_function,
- unicode_literals)
+from __future__ import (division, absolute_import, print_function)
import beets.ui
from beets import logging
@@ -101,24 +100,24 @@ class DiscogsPlugin(BeetsPlugin):
try:
_, _, url = auth_client.get_authorize_url()
except CONNECTION_ERRORS as e:
- self._log.debug('connection error: {0}', e)
- raise beets.ui.UserError('communication with Discogs failed')
+ self._log.debug(u'connection error: {0}', e)
+ raise beets.ui.UserError(u'communication with Discogs failed')
- beets.ui.print_("To authenticate with Discogs, visit:")
+ beets.ui.print_(u"To authenticate with Discogs, visit:")
beets.ui.print_(url)
# Ask for the code and validate it.
- code = beets.ui.input_("Enter the code:")
+ code = beets.ui.input_(u"Enter the code:")
try:
token, secret = auth_client.get_access_token(code)
except DiscogsAPIError:
- raise beets.ui.UserError('Discogs authorization failed')
+ raise beets.ui.UserError(u'Discogs authorization failed')
except CONNECTION_ERRORS as e:
self._log.debug(u'connection error: {0}', e)
- raise beets.ui.UserError('Discogs token request failed')
+ raise beets.ui.UserError(u'Discogs token request failed')
# Save the token for later use.
- self._log.debug('Discogs token {0}, secret {1}', token, secret)
+ self._log.debug(u'Discogs token {0}, secret {1}', token, secret)
with open(self._tokenfile(), 'w') as f:
json.dump({'token': token, 'secret': secret}, f)
@@ -153,7 +152,7 @@ class DiscogsPlugin(BeetsPlugin):
else:
return []
except CONNECTION_ERRORS:
- self._log.debug('Connection error in album search', exc_info=True)
+ self._log.debug(u'Connection error in album search', exc_info=True)
return []
def album_for_id(self, album_id):
@@ -184,7 +183,7 @@ class DiscogsPlugin(BeetsPlugin):
return self.album_for_id(album_id)
return None
except CONNECTION_ERRORS:
- self._log.debug('Connection error in album lookup', exc_info=True)
+ self._log.debug(u'Connection error in album lookup', exc_info=True)
return None
return self.get_album_info(result)
@@ -206,7 +205,7 @@ class DiscogsPlugin(BeetsPlugin):
releases = self.discogs_client.search(query,
type='release').page(1)
except CONNECTION_ERRORS:
- self._log.debug("Communication error while searching for {0!r}",
+ self._log.debug(u"Communication error while searching for {0!r}",
query, exc_info=True)
return []
return [self.get_album_info(release) for release in releases[:5]]