py3k: Change apply() to unpacking syntax

apply() is no longer available in py3k.
This commit is contained in:
Brian Crowell 2012-10-20 16:05:13 -05:00 committed by Brian Crowell
parent e2283c664b
commit 48cf699fe6
5 changed files with 13 additions and 13 deletions

View File

@ -372,8 +372,8 @@ def _getdecoder(mode, decoder_name, args, extra=()):
try: try:
# get decoder # get decoder
decoder = getattr(core, decoder_name + "_decoder") decoder = getattr(core, decoder_name + "_decoder")
# print decoder, (mode,) + args + extra # print(decoder, mode, args + extra)
return apply(decoder, (mode,) + args + extra) return decoder(mode, *args + extra)
except AttributeError: except AttributeError:
raise IOError("decoder %s not available" % decoder_name) raise IOError("decoder %s not available" % decoder_name)
@ -388,8 +388,8 @@ def _getencoder(mode, encoder_name, args, extra=()):
try: try:
# get encoder # get encoder
encoder = getattr(core, encoder_name + "_encoder") encoder = getattr(core, encoder_name + "_encoder")
# print encoder, (mode,) + args + extra # print(encoder, mode, args + extra)
return apply(encoder, (mode,) + args + extra) return encoder(mode, *args + extra)
except AttributeError: except AttributeError:
raise IOError("encoder %s not available" % encoder_name) raise IOError("encoder %s not available" % encoder_name)
@ -601,7 +601,7 @@ class Image:
"Explicitly load pixel data." "Explicitly load pixel data."
if self.im and self.palette and self.palette.dirty: if self.im and self.palette and self.palette.dirty:
# realize palette # realize palette
apply(self.im.putpalette, self.palette.getdata()) self.im.putpalette(*self.palette.getdata())
self.palette.dirty = 0 self.palette.dirty = 0
self.palette.mode = "RGB" self.palette.mode = "RGB"
self.palette.rawmode = None self.palette.rawmode = None
@ -2129,8 +2129,8 @@ def register_extension(id, extension):
def _show(image, **options): def _show(image, **options):
# override me, as necessary # override me, as necessary
apply(_showxv, (image,), options) _showxv(image, **options)
def _showxv(image, title=None, **options): def _showxv(image, title=None, **options):
from . import ImageShow from . import ImageShow
apply(ImageShow.show, (image, title), options) ImageShow.show(image, title, **options)

View File

@ -54,7 +54,7 @@ class Kernel(Filter):
def filter(self, image): def filter(self, image):
if image.mode == "P": if image.mode == "P":
raise ValueError("cannot filter palette images") raise ValueError("cannot filter palette images")
return apply(image.filter, self.filterargs) return image.filter(*self.filterargs)
class BuiltinFilter(Kernel): class BuiltinFilter(Kernel):
def __init__(self): def __init__(self):

View File

@ -117,7 +117,7 @@ class PhotoImage:
self.__mode = mode self.__mode = mode
self.__size = size self.__size = size
self.__photo = apply(tkinter.PhotoImage, (), kw) self.__photo = tkinter.PhotoImage(**kw)
self.tk = self.__photo.tk self.tk = self.__photo.tk
if image: if image:
self.paste(image) self.paste(image)
@ -239,7 +239,7 @@ class BitmapImage:
else: else:
# slow but safe way # slow but safe way
kw["data"] = image.tobitmap() kw["data"] = image.tobitmap()
self.__photo = apply(tkinter.BitmapImage, (), kw) self.__photo = tkinter.BitmapImage(**kw)
def __del__(self): def __del__(self):
name = self.__photo.name name = self.__photo.name

View File

@ -179,7 +179,7 @@ class Window:
) )
def __dispatcher(self, action, *args): def __dispatcher(self, action, *args):
return apply(getattr(self, "ui_handle_" + action), args) return getattr(self, "ui_handle_" + action)(*args)
def ui_handle_clear(self, dc, x0, y0, x1, y1): def ui_handle_clear(self, dc, x0, y0, x1, y1):
pass pass

View File

@ -90,9 +90,9 @@ try:
im.draft(convert, im.size) im.draft(convert, im.size)
im = im.convert(convert) im = im.convert(convert)
if format: if format:
apply(im.save, (argv[1], format), options) im.save(argv[1], format, **options)
else: else:
apply(im.save, (argv[1],), options) im.save(argv[1], **options)
except: except:
print("cannot convert image", end=' ') print("cannot convert image", end=' ')
print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])) print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1]))