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.
This commit is contained in:
Eli Schwartz 2019-05-01 01:16:39 -04:00
parent 9714f722e7
commit d9918b5b9c
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import glob, os, string, shutil import glob, os, shutil
from functools import partial from functools import partial
from PyQt5.Qt import ( from PyQt5.Qt import (
QDialog, QVBoxLayout, QListWidget, QListWidgetItem, Qt, QIcon, QDialog, QVBoxLayout, QListWidget, QListWidgetItem, Qt, QIcon,
@ -72,7 +72,7 @@ class TextureChooser(QDialog):
images = [{ images = [{
'fname': ':'+os.path.basename(x), 'fname': ':'+os.path.basename(x),
'path': 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'))] + [{ } for x in glob.glob(I('textures/*.png'))] + [{
'fname': os.path.basename(x), 'fname': os.path.basename(x),
'path': x, 'path': x,
@ -81,7 +81,8 @@ class TextureChooser(QDialog):
images.sort(key=lambda x:sort_key(x['name'])) 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() self.update_remove_state()
if initial: if initial: