diff --git a/beetsplug/thumbnails.py b/beetsplug/thumbnails.py index ca2a942a9..c9b484d5a 100644 --- a/beetsplug/thumbnails.py +++ b/beetsplug/thumbnails.py @@ -19,8 +19,7 @@ This plugin is POSIX-only. Spec: standards.freedesktop.org/thumbnail-spec/latest/index.html """ -from __future__ import (division, absolute_import, print_function, - unicode_literals) +from __future__ import (division, absolute_import, print_function) from hashlib import md5 import os @@ -58,14 +57,15 @@ class ThumbnailsPlugin(BeetsPlugin): def commands(self): thumbnails_command = Subcommand("thumbnails", - help="Create album thumbnails") + help=u"Create album thumbnails") thumbnails_command.parser.add_option( - '-f', '--force', dest='force', action='store_true', default=False, - help='force regeneration of thumbnails deemed fine (existing & ' - 'recent enough)') + u'-f', u'--force', + dest='force', action='store_true', default=False, + help=u'force regeneration of thumbnails deemed fine (existing & ' + u'recent enough)') thumbnails_command.parser.add_option( - '--dolphin', dest='dolphin', action='store_true', default=False, - help="create Dolphin-compatible thumbnail information (for KDE)") + u'--dolphin', dest='dolphin', action='store_true', default=False, + help=u"create Dolphin-compatible thumbnail information (for KDE)") thumbnails_command.func = self.process_query return [thumbnails_command] @@ -84,8 +84,8 @@ class ThumbnailsPlugin(BeetsPlugin): - detect whether we'll use GIO or Python to get URIs """ if not ArtResizer.shared.local: - self._log.warning("No local image resizing capabilities, " - "cannot generate thumbnails") + self._log.warning(u"No local image resizing capabilities, " + u"cannot generate thumbnails") return False for dir in (NORMAL_DIR, LARGE_DIR): @@ -99,12 +99,12 @@ class ThumbnailsPlugin(BeetsPlugin): assert has_PIL() # since we're local self.write_metadata = write_metadata_pil tool = "PIL" - self._log.debug("using {0} to write metadata", tool) + self._log.debug(u"using {0} to write metadata", tool) uri_getter = GioURI() if not uri_getter.available: uri_getter = PathlibURI() - self._log.debug("using {0.name} to compute URIs", uri_getter) + self._log.debug(u"using {0.name} to compute URIs", uri_getter) self.get_uri = uri_getter.uri return True @@ -122,7 +122,7 @@ class ThumbnailsPlugin(BeetsPlugin): size = ArtResizer.shared.get_size(album.artpath) if not size: - self._log.warning('problem getting the picture size for {0}', + self._log.warning(u'problem getting the picture size for {0}', album.artpath) return @@ -132,9 +132,9 @@ class ThumbnailsPlugin(BeetsPlugin): wrote &= self.make_cover_thumbnail(album, 128, NORMAL_DIR) if wrote: - self._log.info('wrote thumbnail for {0}', album) + self._log.info(u'wrote thumbnail for {0}', album) else: - self._log.info('nothing to do for {0}', album) + self._log.info(u'nothing to do for {0}', album) def make_cover_thumbnail(self, album, size, target_dir): """Make a thumbnail of given size for `album` and put it in @@ -145,11 +145,11 @@ class ThumbnailsPlugin(BeetsPlugin): if os.path.exists(target) and \ os.stat(target).st_mtime > os.stat(album.artpath).st_mtime: if self.config['force']: - self._log.debug("found a suitable {1}x{1} thumbnail for {0}, " - "forcing regeneration", album, size) + self._log.debug(u"found a suitable {1}x{1} thumbnail for {0}, " + u"forcing regeneration", album, size) else: - self._log.debug("{1}x{1} thumbnail for {0} exists and is " - "recent enough", album, size) + self._log.debug(u"{1}x{1} thumbnail for {0} exists and is " + u"recent enough", album, size) return False resized = ArtResizer.shared.resize(size, album.artpath, util.syspath(target)) @@ -174,7 +174,7 @@ class ThumbnailsPlugin(BeetsPlugin): try: self.write_metadata(image_path, metadata) except Exception: - self._log.exception("could not write metadata to {0}", + self._log.exception(u"could not write metadata to {0}", util.displayable_path(image_path)) def make_dolphin_cover_thumbnail(self, album): @@ -185,7 +185,7 @@ class ThumbnailsPlugin(BeetsPlugin): with open(outfilename, 'w') as f: f.write(b"[Desktop Entry]\nIcon=./{0}".format(artfile)) f.close() - self._log.debug("Wrote file {0}", util.displayable_path(outfilename)) + self._log.debug(u"Wrote file {0}", util.displayable_path(outfilename)) def write_metadata_im(file, metadata): @@ -266,7 +266,7 @@ class GioURI(URIGetter): def uri(self, path): g_file_ptr = self.libgio.g_file_new_for_path(path) if not g_file_ptr: - raise RuntimeError("No gfile pointer received for {0}".format( + raise RuntimeError(u"No gfile pointer received for {0}".format( util.displayable_path(path))) try: @@ -277,8 +277,8 @@ class GioURI(URIGetter): self.libgio.g_object_unref(g_file_ptr) if not uri_ptr: self.libgio.g_free(uri_ptr) - raise RuntimeError("No URI received from the gfile pointer for " - "{0}".format(util.displayable_path(path))) + raise RuntimeError(u"No URI received from the gfile pointer for " + u"{0}".format(util.displayable_path(path))) try: uri = copy_c_string(uri_ptr) diff --git a/beetsplug/types.py b/beetsplug/types.py index 4c5d20a45..40e504f27 100644 --- a/beetsplug/types.py +++ b/beetsplug/types.py @@ -13,8 +13,7 @@ # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -from __future__ import (division, absolute_import, print_function, - unicode_literals) +from __future__ import (division, absolute_import, print_function) from beets.plugins import BeetsPlugin from beets.dbcore import types