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:
# get decoder
decoder = getattr(core, decoder_name + "_decoder")
# print decoder, (mode,) + args + extra
return apply(decoder, (mode,) + args + extra)
# print(decoder, mode, args + extra)
return decoder(mode, *args + extra)
except AttributeError:
raise IOError("decoder %s not available" % decoder_name)
@ -388,8 +388,8 @@ def _getencoder(mode, encoder_name, args, extra=()):
try:
# get encoder
encoder = getattr(core, encoder_name + "_encoder")
# print encoder, (mode,) + args + extra
return apply(encoder, (mode,) + args + extra)
# print(encoder, mode, args + extra)
return encoder(mode, *args + extra)
except AttributeError:
raise IOError("encoder %s not available" % encoder_name)
@ -601,7 +601,7 @@ class Image:
"Explicitly load pixel data."
if self.im and self.palette and self.palette.dirty:
# realize palette
apply(self.im.putpalette, self.palette.getdata())
self.im.putpalette(*self.palette.getdata())
self.palette.dirty = 0
self.palette.mode = "RGB"
self.palette.rawmode = None
@ -2129,8 +2129,8 @@ def register_extension(id, extension):
def _show(image, **options):
# override me, as necessary
apply(_showxv, (image,), options)
_showxv(image, **options)
def _showxv(image, title=None, **options):
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):
if image.mode == "P":
raise ValueError("cannot filter palette images")
return apply(image.filter, self.filterargs)
return image.filter(*self.filterargs)
class BuiltinFilter(Kernel):
def __init__(self):

View File

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

View File

@ -179,7 +179,7 @@ class Window:
)
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):
pass

View File

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