From fa73879d190b9e528ac6aae756b4b0df8d4a21f0 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 4 Jul 2015 23:29:58 +1000 Subject: [PATCH] Changed register calls to use format property --- PIL/CurImagePlugin.py | 4 ++-- PIL/DcxImagePlugin.py | 4 ++-- PIL/FliImagePlugin.py | 6 +++--- PIL/GbrImagePlugin.py | 4 ++-- PIL/IcnsImagePlugin.py | 9 +++++---- PIL/IcoImagePlugin.py | 6 +++--- PIL/ImImagePlugin.py | 6 +++--- PIL/IptcImagePlugin.py | 4 ++-- PIL/Jpeg2KImagePlugin.py | 20 ++++++++++---------- PIL/JpegImagePlugin.py | 14 +++++++------- PIL/MicImagePlugin.py | 4 ++-- PIL/MpegImagePlugin.py | 8 ++++---- PIL/MpoImagePlugin.py | 9 +++++---- PIL/MspImagePlugin.py | 6 +++--- PIL/PcdImagePlugin.py | 4 ++-- PIL/PcxImagePlugin.py | 6 +++--- PIL/PngImagePlugin.py | 8 ++++---- PIL/PpmImagePlugin.py | 10 +++++----- PIL/PsdImagePlugin.py | 4 ++-- PIL/SgiImagePlugin.py | 10 +++++----- PIL/SpiderImagePlugin.py | 4 ++-- PIL/SunImagePlugin.py | 4 ++-- PIL/TgaImagePlugin.py | 6 +++--- PIL/TiffImagePlugin.py | 10 +++++----- PIL/WebPImagePlugin.py | 8 ++++---- PIL/XbmImagePlugin.py | 8 ++++---- PIL/XpmImagePlugin.py | 6 +++--- 27 files changed, 97 insertions(+), 95 deletions(-) diff --git a/PIL/CurImagePlugin.py b/PIL/CurImagePlugin.py index 0178957ee..8707eeeb3 100644 --- a/PIL/CurImagePlugin.py +++ b/PIL/CurImagePlugin.py @@ -82,6 +82,6 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): # # -------------------------------------------------------------------- -Image.register_open("CUR", CurImageFile, _accept) +Image.register_open(CurImageFile.format, CurImageFile, _accept) -Image.register_extension("CUR", ".cur") +Image.register_extension(CurImageFile.format, ".cur") diff --git a/PIL/DcxImagePlugin.py b/PIL/DcxImagePlugin.py index c6c9b8773..4c4bf700c 100644 --- a/PIL/DcxImagePlugin.py +++ b/PIL/DcxImagePlugin.py @@ -82,6 +82,6 @@ class DcxImageFile(PcxImageFile): return self.frame -Image.register_open("DCX", DcxImageFile, _accept) +Image.register_open(DcxImageFile.format, DcxImageFile, _accept) -Image.register_extension("DCX", ".dcx") +Image.register_extension(DcxImageFile.format, ".dcx") diff --git a/PIL/FliImagePlugin.py b/PIL/FliImagePlugin.py index e3eaff970..1af9dadde 100644 --- a/PIL/FliImagePlugin.py +++ b/PIL/FliImagePlugin.py @@ -182,7 +182,7 @@ class FliImageFile(ImageFile.ImageFile): # # registry -Image.register_open("FLI", FliImageFile, _accept) +Image.register_open(FliImageFile.format, FliImageFile, _accept) -Image.register_extension("FLI", ".fli") -Image.register_extension("FLI", ".flc") +Image.register_extension(FliImageFile.format, ".fli") +Image.register_extension(FliImageFile.format, ".flc") diff --git a/PIL/GbrImagePlugin.py b/PIL/GbrImagePlugin.py index b512efd25..15282ecee 100644 --- a/PIL/GbrImagePlugin.py +++ b/PIL/GbrImagePlugin.py @@ -66,6 +66,6 @@ class GbrImageFile(ImageFile.ImageFile): # # registry -Image.register_open("GBR", GbrImageFile, _accept) +Image.register_open(GbrImageFile.format, GbrImageFile, _accept) -Image.register_extension("GBR", ".gbr") +Image.register_extension(GbrImageFile.format, ".gbr") diff --git a/PIL/IcnsImagePlugin.py b/PIL/IcnsImagePlugin.py index e0b130e81..060596b48 100644 --- a/PIL/IcnsImagePlugin.py +++ b/PIL/IcnsImagePlugin.py @@ -345,13 +345,14 @@ def _save(im, fp, filename): if retcode: raise CalledProcessError(retcode, convert_cmd) -Image.register_open("ICNS", IcnsImageFile, lambda x: x[:4] == b'icns') -Image.register_extension("ICNS", '.icns') +Image.register_open(IcnsImageFile.format, IcnsImageFile, + lambda x: x[:4] == b'icns') +Image.register_extension(IcnsImageFile.format, '.icns') if sys.platform == 'darwin': - Image.register_save("ICNS", _save) + Image.register_save(IcnsImageFile.format, _save) - Image.register_mime("ICNS", "image/icns") + Image.register_mime(IcnsImageFile.format, "image/icns") if __name__ == '__main__': diff --git a/PIL/IcoImagePlugin.py b/PIL/IcoImagePlugin.py index 778edaf9a..9feafea1b 100644 --- a/PIL/IcoImagePlugin.py +++ b/PIL/IcoImagePlugin.py @@ -278,6 +278,6 @@ class IcoImageFile(ImageFile.ImageFile): # # -------------------------------------------------------------------- -Image.register_open("ICO", IcoImageFile, _accept) -Image.register_save("ICO", _save) -Image.register_extension("ICO", ".ico") +Image.register_open(IcoImageFile.format, IcoImageFile, _accept) +Image.register_save(IcoImageFile.format, _save) +Image.register_extension(IcoImageFile.format, ".ico") diff --git a/PIL/ImImagePlugin.py b/PIL/ImImagePlugin.py index 0a0a666ce..1e5d6860c 100644 --- a/PIL/ImImagePlugin.py +++ b/PIL/ImImagePlugin.py @@ -349,7 +349,7 @@ def _save(im, fp, filename, check=0): # -------------------------------------------------------------------- # Registry -Image.register_open("IM", ImImageFile) -Image.register_save("IM", _save) +Image.register_open(ImImageFile.format, ImImageFile) +Image.register_save(ImImageFile.format, _save) -Image.register_extension("IM", ".im") +Image.register_extension(ImImageFile.format, ".im") diff --git a/PIL/IptcImagePlugin.py b/PIL/IptcImagePlugin.py index 47c7e1936..e810ffca2 100644 --- a/PIL/IptcImagePlugin.py +++ b/PIL/IptcImagePlugin.py @@ -184,9 +184,9 @@ class IptcImageFile(ImageFile.ImageFile): pass -Image.register_open("IPTC", IptcImageFile) +Image.register_open(IptcImageFile.format, IptcImageFile) -Image.register_extension("IPTC", ".iim") +Image.register_extension(IptcImageFile.format, ".iim") ## diff --git a/PIL/Jpeg2KImagePlugin.py b/PIL/Jpeg2KImagePlugin.py index ed3e1530a..b82acdd98 100644 --- a/PIL/Jpeg2KImagePlugin.py +++ b/PIL/Jpeg2KImagePlugin.py @@ -262,15 +262,15 @@ def _save(im, fp, filename): # ------------------------------------------------------------ # Registry stuff -Image.register_open('JPEG2000', Jpeg2KImageFile, _accept) -Image.register_save('JPEG2000', _save) +Image.register_open(Jpeg2KImageFile.format, Jpeg2KImageFile, _accept) +Image.register_save(Jpeg2KImageFile.format, _save) -Image.register_extension('JPEG2000', '.jp2') -Image.register_extension('JPEG2000', '.j2k') -Image.register_extension('JPEG2000', '.jpc') -Image.register_extension('JPEG2000', '.jpf') -Image.register_extension('JPEG2000', '.jpx') -Image.register_extension('JPEG2000', '.j2c') +Image.register_extension(Jpeg2KImageFile.format, '.jp2') +Image.register_extension(Jpeg2KImageFile.format, '.j2k') +Image.register_extension(Jpeg2KImageFile.format, '.jpc') +Image.register_extension(Jpeg2KImageFile.format, '.jpf') +Image.register_extension(Jpeg2KImageFile.format, '.jpx') +Image.register_extension(Jpeg2KImageFile.format, '.j2c') -Image.register_mime('JPEG2000', 'image/jp2') -Image.register_mime('JPEG2000', 'image/jpx') +Image.register_mime(Jpeg2KImageFile.format, 'image/jp2') +Image.register_mime(Jpeg2KImageFile.format, 'image/jpx') diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 5cae90073..f5600c42f 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -728,12 +728,12 @@ def jpeg_factory(fp=None, filename=None): # -------------------------------------------------------------------q- # Registry stuff -Image.register_open("JPEG", jpeg_factory, _accept) -Image.register_save("JPEG", _save) +Image.register_open(JpegImageFile.format, jpeg_factory, _accept) +Image.register_save(JpegImageFile.format, _save) -Image.register_extension("JPEG", ".jfif") -Image.register_extension("JPEG", ".jpe") -Image.register_extension("JPEG", ".jpg") -Image.register_extension("JPEG", ".jpeg") +Image.register_extension(JpegImageFile.format, ".jfif") +Image.register_extension(JpegImageFile.format, ".jpe") +Image.register_extension(JpegImageFile.format, ".jpg") +Image.register_extension(JpegImageFile.format, ".jpeg") -Image.register_mime("JPEG", "image/jpeg") +Image.register_mime(JpegImageFile.format, "image/jpeg") diff --git a/PIL/MicImagePlugin.py b/PIL/MicImagePlugin.py index 8e3e1b11d..053f66c07 100644 --- a/PIL/MicImagePlugin.py +++ b/PIL/MicImagePlugin.py @@ -99,6 +99,6 @@ class MicImageFile(TiffImagePlugin.TiffImageFile): # # -------------------------------------------------------------------- -Image.register_open("MIC", MicImageFile, _accept) +Image.register_open(MicImageFile.format, MicImageFile, _accept) -Image.register_extension("MIC", ".mic") +Image.register_extension(MicImageFile.format, ".mic") diff --git a/PIL/MpegImagePlugin.py b/PIL/MpegImagePlugin.py index ff7c0dce4..04cf755f3 100644 --- a/PIL/MpegImagePlugin.py +++ b/PIL/MpegImagePlugin.py @@ -77,9 +77,9 @@ class MpegImageFile(ImageFile.ImageFile): # -------------------------------------------------------------------- # Registry stuff -Image.register_open("MPEG", MpegImageFile) +Image.register_open(MpegImageFile.format, MpegImageFile) -Image.register_extension("MPEG", ".mpg") -Image.register_extension("MPEG", ".mpeg") +Image.register_extension(MpegImageFile.format, ".mpg") +Image.register_extension(MpegImageFile.format, ".mpeg") -Image.register_mime("MPEG", "video/mpeg") +Image.register_mime(MpegImageFile.format, "video/mpeg") diff --git a/PIL/MpoImagePlugin.py b/PIL/MpoImagePlugin.py index b7e6c5756..7eb8f4cf8 100644 --- a/PIL/MpoImagePlugin.py +++ b/PIL/MpoImagePlugin.py @@ -90,9 +90,10 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile): # Note that since MPO shares a factory with JPEG, we do not need to do a # separate registration for it here. -# Image.register_open("MPO", JpegImagePlugin.jpeg_factory, _accept) -Image.register_save("MPO", _save) +# Image.register_open(MpoImageFile.format, +# JpegImagePlugin.jpeg_factory, _accept) +Image.register_save(MpoImageFile.format, _save) -Image.register_extension("MPO", ".mpo") +Image.register_extension(MpoImageFile.format, ".mpo") -Image.register_mime("MPO", "image/mpo") +Image.register_mime(MpoImageFile.format, "image/mpo") diff --git a/PIL/MspImagePlugin.py b/PIL/MspImagePlugin.py index 1e974d53f..49dd45b31 100644 --- a/PIL/MspImagePlugin.py +++ b/PIL/MspImagePlugin.py @@ -98,7 +98,7 @@ def _save(im, fp, filename): # # registry -Image.register_open("MSP", MspImageFile, _accept) -Image.register_save("MSP", _save) +Image.register_open(MspImageFile.format, MspImageFile, _accept) +Image.register_save(MspImageFile.format, _save) -Image.register_extension("MSP", ".msp") +Image.register_extension(MspImageFile.format, ".msp") diff --git a/PIL/PcdImagePlugin.py b/PIL/PcdImagePlugin.py index 06db5d628..4481671b1 100644 --- a/PIL/PcdImagePlugin.py +++ b/PIL/PcdImagePlugin.py @@ -55,6 +55,6 @@ class PcdImageFile(ImageFile.ImageFile): # # registry -Image.register_open("PCD", PcdImageFile) +Image.register_open(PcdImageFile.format, PcdImageFile) -Image.register_extension("PCD", ".pcd") +Image.register_extension(PcdImageFile.format, ".pcd") diff --git a/PIL/PcxImagePlugin.py b/PIL/PcxImagePlugin.py index 906c38a35..9440d5362 100644 --- a/PIL/PcxImagePlugin.py +++ b/PIL/PcxImagePlugin.py @@ -181,7 +181,7 @@ def _save(im, fp, filename, check=0): # -------------------------------------------------------------------- # registry -Image.register_open("PCX", PcxImageFile, _accept) -Image.register_save("PCX", _save) +Image.register_open(PcxImageFile.format, PcxImageFile, _accept) +Image.register_save(PcxImageFile.format, _save) -Image.register_extension("PCX", ".pcx") +Image.register_extension(PcxImageFile.format, ".pcx") diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 9fcc9fe4e..a2bc8f679 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -803,9 +803,9 @@ def getchunks(im, **params): # -------------------------------------------------------------------- # Registry -Image.register_open("PNG", PngImageFile, _accept) -Image.register_save("PNG", _save) +Image.register_open(PngImageFile.format, PngImageFile, _accept) +Image.register_save(PngImageFile.format, _save) -Image.register_extension("PNG", ".png") +Image.register_extension(PngImageFile.format, ".png") -Image.register_mime("PNG", "image/png") +Image.register_mime(PngImageFile.format, "image/png") diff --git a/PIL/PpmImagePlugin.py b/PIL/PpmImagePlugin.py index 954832451..d829532e5 100644 --- a/PIL/PpmImagePlugin.py +++ b/PIL/PpmImagePlugin.py @@ -164,9 +164,9 @@ def _save(im, fp, filename): # # -------------------------------------------------------------------- -Image.register_open("PPM", PpmImageFile, _accept) -Image.register_save("PPM", _save) +Image.register_open(PpmImageFile.format, PpmImageFile, _accept) +Image.register_save(PpmImageFile.format, _save) -Image.register_extension("PPM", ".pbm") -Image.register_extension("PPM", ".pgm") -Image.register_extension("PPM", ".ppm") +Image.register_extension(PpmImageFile.format, ".pbm") +Image.register_extension(PpmImageFile.format, ".pgm") +Image.register_extension(PpmImageFile.format, ".ppm") diff --git a/PIL/PsdImagePlugin.py b/PIL/PsdImagePlugin.py index 030f5144c..d06e320b0 100644 --- a/PIL/PsdImagePlugin.py +++ b/PIL/PsdImagePlugin.py @@ -307,6 +307,6 @@ def _maketile(file, mode, bbox, channels): # -------------------------------------------------------------------- # registry -Image.register_open("PSD", PsdImageFile, _accept) +Image.register_open(PsdImageFile.format, PsdImageFile, _accept) -Image.register_extension("PSD", ".psd") +Image.register_extension(PsdImageFile.format, ".psd") diff --git a/PIL/SgiImagePlugin.py b/PIL/SgiImagePlugin.py index 6219ecebf..9b4535ebf 100644 --- a/PIL/SgiImagePlugin.py +++ b/PIL/SgiImagePlugin.py @@ -81,11 +81,11 @@ class SgiImageFile(ImageFile.ImageFile): # # registry -Image.register_open("SGI", SgiImageFile, _accept) +Image.register_open(SgiImageFile.format, SgiImageFile, _accept) -Image.register_extension("SGI", ".bw") -Image.register_extension("SGI", ".rgb") -Image.register_extension("SGI", ".rgba") -Image.register_extension("SGI", ".sgi") +Image.register_extension(SgiImageFile.format, ".bw") +Image.register_extension(SgiImageFile.format, ".rgb") +Image.register_extension(SgiImageFile.format, ".rgba") +Image.register_extension(SgiImageFile.format, ".sgi") # End of file diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index f306538ae..6344a1540 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -285,8 +285,8 @@ def _save_spider(im, fp, filename): # -------------------------------------------------------------------- -Image.register_open("SPIDER", SpiderImageFile) -Image.register_save("SPIDER", _save_spider) +Image.register_open(SpiderImageFile.format, SpiderImageFile) +Image.register_save(SpiderImageFile.format, _save_spider) if __name__ == "__main__": diff --git a/PIL/SunImagePlugin.py b/PIL/SunImagePlugin.py index b03924ac6..f6c598a3f 100644 --- a/PIL/SunImagePlugin.py +++ b/PIL/SunImagePlugin.py @@ -78,6 +78,6 @@ class SunImageFile(ImageFile.ImageFile): # # registry -Image.register_open("SUN", SunImageFile, _accept) +Image.register_open(SunImageFile.format, SunImageFile, _accept) -Image.register_extension("SUN", ".ras") +Image.register_extension(SunImageFile.format, ".ras") diff --git a/PIL/TgaImagePlugin.py b/PIL/TgaImagePlugin.py index 46eafe8d0..75fa1c7e6 100644 --- a/PIL/TgaImagePlugin.py +++ b/PIL/TgaImagePlugin.py @@ -193,7 +193,7 @@ def _save(im, fp, filename, check=0): # -------------------------------------------------------------------- # Registry -Image.register_open("TGA", TgaImageFile) -Image.register_save("TGA", _save) +Image.register_open(TgaImageFile.format, TgaImageFile) +Image.register_save(TgaImageFile.format, _save) -Image.register_extension("TGA", ".tga") +Image.register_extension(TgaImageFile.format, ".tga") diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 9d6e56abf..029690f2f 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1262,10 +1262,10 @@ def _save(im, fp, filename): # -------------------------------------------------------------------- # Register -Image.register_open("TIFF", TiffImageFile, _accept) -Image.register_save("TIFF", _save) +Image.register_open(TiffImageFile.format, TiffImageFile, _accept) +Image.register_save(TiffImageFile.format, _save) -Image.register_extension("TIFF", ".tif") -Image.register_extension("TIFF", ".tiff") +Image.register_extension(TiffImageFile.format, ".tif") +Image.register_extension(TiffImageFile.format, ".tiff") -Image.register_mime("TIFF", "image/tiff") +Image.register_mime(TiffImageFile.format, "image/tiff") diff --git a/PIL/WebPImagePlugin.py b/PIL/WebPImagePlugin.py index 78a7a5319..6837b53be 100644 --- a/PIL/WebPImagePlugin.py +++ b/PIL/WebPImagePlugin.py @@ -73,8 +73,8 @@ def _save(im, fp, filename): fp.write(data) -Image.register_open("WEBP", WebPImageFile, _accept) -Image.register_save("WEBP", _save) +Image.register_open(WebPImageFile.format, WebPImageFile, _accept) +Image.register_save(WebPImageFile.format, _save) -Image.register_extension("WEBP", ".webp") -Image.register_mime("WEBP", "image/webp") +Image.register_extension(WebPImageFile.format, ".webp") +Image.register_mime(WebPImageFile.format, "image/webp") diff --git a/PIL/XbmImagePlugin.py b/PIL/XbmImagePlugin.py index 454a95534..6916e1888 100644 --- a/PIL/XbmImagePlugin.py +++ b/PIL/XbmImagePlugin.py @@ -88,9 +88,9 @@ def _save(im, fp, filename): fp.write(b"};\n") -Image.register_open("XBM", XbmImageFile, _accept) -Image.register_save("XBM", _save) +Image.register_open(XbmImageFile.format, XbmImageFile, _accept) +Image.register_save(XbmImageFile.format, _save) -Image.register_extension("XBM", ".xbm") +Image.register_extension(XbmImageFile.format, ".xbm") -Image.register_mime("XBM", "image/xbm") +Image.register_mime(XbmImageFile.format, "image/xbm") diff --git a/PIL/XpmImagePlugin.py b/PIL/XpmImagePlugin.py index 517580895..522302706 100644 --- a/PIL/XpmImagePlugin.py +++ b/PIL/XpmImagePlugin.py @@ -124,8 +124,8 @@ class XpmImageFile(ImageFile.ImageFile): # # Registry -Image.register_open("XPM", XpmImageFile, _accept) +Image.register_open(XpmImageFile.format, XpmImageFile, _accept) -Image.register_extension("XPM", ".xpm") +Image.register_extension(XpmImageFile.format, ".xpm") -Image.register_mime("XPM", "image/xpm") +Image.register_mime(XpmImageFile.format, "image/xpm")