From d9918b5b9c3c9cae9073f22c1fc00665dd29dfb2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 1 May 2019 01:16:39 -0400 Subject: [PATCH] py3: make cover grid texture selection work map() is an iterable, so using it as a shortcut for a proper for loop in order to apply functions, is no longer valid. Also move from the long deprecated string.*() functions -- which no longer exist in python3 -- that are better dealt with through the native str/unicode type methods. --- src/calibre/gui2/preferences/texture_chooser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/preferences/texture_chooser.py b/src/calibre/gui2/preferences/texture_chooser.py index fdd5c09fa0..b1a80cfdd6 100644 --- a/src/calibre/gui2/preferences/texture_chooser.py +++ b/src/calibre/gui2/preferences/texture_chooser.py @@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -import glob, os, string, shutil +import glob, os, shutil from functools import partial from PyQt5.Qt import ( QDialog, QVBoxLayout, QListWidget, QListWidgetItem, Qt, QIcon, @@ -72,7 +72,7 @@ class TextureChooser(QDialog): images = [{ 'fname': ':'+os.path.basename(x), 'path': x, - 'name': ' '.join(map(string.capitalize, os.path.splitext(os.path.basename(x))[0].split('_'))) + 'name': ' '.join(map(lambda s: s.capitalize(), os.path.splitext(os.path.basename(x))[0].split('_'))) } for x in glob.glob(I('textures/*.png'))] + [{ 'fname': os.path.basename(x), 'path': x, @@ -81,7 +81,8 @@ class TextureChooser(QDialog): images.sort(key=lambda x:sort_key(x['name'])) - map(self.create_item, images) + for i in images: + self.create_item(i) self.update_remove_state() if initial: