mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Replaced old-style classes
This commit is contained in:
parent
77f7cfd370
commit
3c7e37d2d7
|
@ -19,7 +19,7 @@
|
|||
# file (for example a TAR file).
|
||||
|
||||
|
||||
class ContainerIO:
|
||||
class ContainerIO(object):
|
||||
|
||||
##
|
||||
# Create file object.
|
||||
|
|
|
@ -157,7 +157,7 @@ def Ghostscript(tile, size, fp, scale=1):
|
|||
return im
|
||||
|
||||
|
||||
class PSFile:
|
||||
class PSFile(object):
|
||||
"""
|
||||
Wrapper for bytesio object that treats either CR or LF as end of line.
|
||||
"""
|
||||
|
@ -365,7 +365,7 @@ def _save(im, fp, filename, eps=1):
|
|||
else:
|
||||
raise ValueError("image mode is not supported")
|
||||
|
||||
class NoCloseStream:
|
||||
class NoCloseStream(object):
|
||||
def __init__(self, fp):
|
||||
self.fp = fp
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def puti16(fp, values):
|
|||
##
|
||||
# Base class for raster font file handlers.
|
||||
|
||||
class FontFile:
|
||||
class FontFile(object):
|
||||
|
||||
bitmap = None
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ def getdata(im, offset=(0, 0), **params):
|
|||
The first string is a local image header, the rest contains
|
||||
encoded image data."""
|
||||
|
||||
class Collector:
|
||||
class Collector(object):
|
||||
data = []
|
||||
|
||||
def write(self, data):
|
||||
|
|
|
@ -58,7 +58,7 @@ def sphere_decreasing(middle, pos):
|
|||
SEGMENTS = [linear, curved, sine, sphere_increasing, sphere_decreasing]
|
||||
|
||||
|
||||
class GradientFile:
|
||||
class GradientFile(object):
|
||||
|
||||
gradient = None
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from PIL._binary import o8
|
|||
##
|
||||
# File handler for GIMP's palette format.
|
||||
|
||||
class GimpPaletteFile:
|
||||
class GimpPaletteFile(object):
|
||||
|
||||
rawmode = "RGB"
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ def read_png_or_jpeg2000(fobj, start_length, size):
|
|||
raise ValueError('Unsupported icon subimage format')
|
||||
|
||||
|
||||
class IcnsFile:
|
||||
class IcnsFile(object):
|
||||
|
||||
SIZES = {
|
||||
(512, 512, 2): [
|
||||
|
|
|
@ -79,7 +79,7 @@ def _accept(prefix):
|
|||
return prefix[:4] == _MAGIC
|
||||
|
||||
|
||||
class IcoFile:
|
||||
class IcoFile(object):
|
||||
def __init__(self, buf):
|
||||
"""
|
||||
Parse image from file-like object containing ico file data
|
||||
|
|
10
PIL/Image.py
10
PIL/Image.py
|
@ -35,7 +35,7 @@ class DecompressionBombWarning(RuntimeWarning):
|
|||
pass
|
||||
|
||||
|
||||
class _imaging_not_installed:
|
||||
class _imaging_not_installed(object):
|
||||
# module placeholder
|
||||
def __getattr__(self, id):
|
||||
raise ImportError("The _imaging C module is not installed")
|
||||
|
@ -443,7 +443,7 @@ def coerce_e(value):
|
|||
return value if isinstance(value, _E) else _E(value)
|
||||
|
||||
|
||||
class _E:
|
||||
class _E(object):
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
|
@ -478,7 +478,7 @@ def _getscaleoffset(expr):
|
|||
# --------------------------------------------------------------------
|
||||
# Implementation wrapper
|
||||
|
||||
class Image:
|
||||
class Image(object):
|
||||
"""
|
||||
This class represents an image object. To create
|
||||
:py:class:`~PIL.Image.Image` objects, use the appropriate factory
|
||||
|
@ -1975,12 +1975,12 @@ class _ImageCrop(Image):
|
|||
# --------------------------------------------------------------------
|
||||
# Abstract handlers.
|
||||
|
||||
class ImagePointHandler:
|
||||
class ImagePointHandler(object):
|
||||
# used as a mixin by point transforms (for use with im.point)
|
||||
pass
|
||||
|
||||
|
||||
class ImageTransformHandler:
|
||||
class ImageTransformHandler(object):
|
||||
# used as a mixin by geometry transforms (for use with im.transform)
|
||||
pass
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ for flag in FLAGS.values():
|
|||
##
|
||||
# Profile.
|
||||
|
||||
class ImageCmsProfile:
|
||||
class ImageCmsProfile(object):
|
||||
|
||||
def __init__(self, profile):
|
||||
"""
|
||||
|
|
|
@ -47,7 +47,7 @@ except ImportError:
|
|||
# Application code should use the <b>Draw</b> factory, instead of
|
||||
# directly.
|
||||
|
||||
class ImageDraw:
|
||||
class ImageDraw(object):
|
||||
|
||||
##
|
||||
# Create a drawing instance.
|
||||
|
|
|
@ -19,25 +19,25 @@
|
|||
from PIL import Image, ImageColor, ImageDraw, ImageFont, ImagePath
|
||||
|
||||
|
||||
class Pen:
|
||||
class Pen(object):
|
||||
def __init__(self, color, width=1, opacity=255):
|
||||
self.color = ImageColor.getrgb(color)
|
||||
self.width = width
|
||||
|
||||
|
||||
class Brush:
|
||||
class Brush(object):
|
||||
def __init__(self, color, opacity=255):
|
||||
self.color = ImageColor.getrgb(color)
|
||||
|
||||
|
||||
class Font:
|
||||
class Font(object):
|
||||
def __init__(self, color, file, size=12):
|
||||
# FIXME: add support for bitmap fonts
|
||||
self.color = ImageColor.getrgb(color)
|
||||
self.font = ImageFont.truetype(file, size)
|
||||
|
||||
|
||||
class Draw:
|
||||
class Draw(object):
|
||||
|
||||
def __init__(self, image, size=None, color=None):
|
||||
if not hasattr(image, "im"):
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
from PIL import Image, ImageFilter, ImageStat
|
||||
|
||||
|
||||
class _Enhance:
|
||||
class _Enhance(object):
|
||||
|
||||
def enhance(self, factor):
|
||||
"""
|
||||
|
|
|
@ -311,7 +311,7 @@ class StubImageFile(ImageFile):
|
|||
)
|
||||
|
||||
|
||||
class Parser:
|
||||
class Parser(object):
|
||||
"""
|
||||
Incremental image parser. This class implements the standard
|
||||
feed/close consumer interface.
|
||||
|
|
|
@ -38,7 +38,7 @@ except ImportError:
|
|||
warnings = None
|
||||
|
||||
|
||||
class _imagingft_not_installed:
|
||||
class _imagingft_not_installed(object):
|
||||
# module placeholder
|
||||
def __getattr__(self, id):
|
||||
raise ImportError("The _imagingft C module is not installed")
|
||||
|
@ -64,7 +64,7 @@ except ImportError:
|
|||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
class ImageFont:
|
||||
class ImageFont(object):
|
||||
"PIL font wrapper"
|
||||
|
||||
def _load_pilfont(self, filename):
|
||||
|
@ -120,7 +120,7 @@ class ImageFont:
|
|||
# Wrapper for FreeType fonts. Application code should use the
|
||||
# <b>truetype</b> factory function to create font objects.
|
||||
|
||||
class FreeTypeFont:
|
||||
class FreeTypeFont(object):
|
||||
"FreeType font wrapper (requires _imagingft service)"
|
||||
|
||||
def __init__(self, font=None, size=10, index=0, encoding="", file=None):
|
||||
|
@ -193,7 +193,7 @@ class FreeTypeFont:
|
|||
# Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.
|
||||
|
||||
|
||||
class TransposedFont:
|
||||
class TransposedFont(object):
|
||||
"Wrapper for writing rotated or mirrored text"
|
||||
|
||||
def __init__(self, font, orientation=None):
|
||||
|
|
|
@ -31,7 +31,7 @@ def _isconstant(v):
|
|||
return isinstance(v, int) or isinstance(v, float)
|
||||
|
||||
|
||||
class _Operand:
|
||||
class _Operand(object):
|
||||
# wraps an image operand, providing standard operators
|
||||
|
||||
def __init__(self, im):
|
||||
|
|
|
@ -20,7 +20,7 @@ _modes = {}
|
|||
##
|
||||
# Wrapper for mode strings.
|
||||
|
||||
class ModeDescriptor:
|
||||
class ModeDescriptor(object):
|
||||
|
||||
def __init__(self, mode, bands, basemode, basetype):
|
||||
self.mode = mode
|
||||
|
|
|
@ -12,7 +12,7 @@ import re
|
|||
LUT_SIZE = 1 << 9
|
||||
|
||||
|
||||
class LutBuilder:
|
||||
class LutBuilder(object):
|
||||
"""A class for building a MorphLut from a descriptive language
|
||||
|
||||
The input patterns is a list of a strings sequences like these::
|
||||
|
@ -176,7 +176,7 @@ class LutBuilder:
|
|||
return self.lut
|
||||
|
||||
|
||||
class MorphOp:
|
||||
class MorphOp(object):
|
||||
"""A class for binary morphological operators"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
|
@ -21,7 +21,7 @@ import warnings
|
|||
from PIL import ImageColor
|
||||
|
||||
|
||||
class ImagePalette:
|
||||
class ImagePalette(object):
|
||||
"Color palette for palette mapped images"
|
||||
|
||||
def __init__(self, mode="RGB", palette=None, size=0):
|
||||
|
|
|
@ -20,7 +20,7 @@ from PIL import Image
|
|||
# the Python class below is overridden by the C implementation.
|
||||
|
||||
|
||||
class Path:
|
||||
class Path(object):
|
||||
|
||||
def __init__(self, xy):
|
||||
pass
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
##
|
||||
|
||||
|
||||
class Iterator:
|
||||
class Iterator(object):
|
||||
"""
|
||||
This class implements an iterator object that can be used to loop
|
||||
over an image sequence.
|
||||
|
|
|
@ -56,7 +56,7 @@ def show(image, title=None, **options):
|
|||
##
|
||||
# Base class for viewers.
|
||||
|
||||
class Viewer:
|
||||
class Viewer(object):
|
||||
|
||||
# main api
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import operator
|
|||
import functools
|
||||
|
||||
|
||||
class Stat:
|
||||
class Stat(object):
|
||||
|
||||
def __init__(self, image_or_list, mask=None):
|
||||
try:
|
||||
|
|
|
@ -56,7 +56,7 @@ def _pilbitmap_check():
|
|||
# --------------------------------------------------------------------
|
||||
# PhotoImage
|
||||
|
||||
class PhotoImage:
|
||||
class PhotoImage(object):
|
||||
"""
|
||||
A Tkinter-compatible photo image. This can be used
|
||||
everywhere Tkinter expects an image object. If the image is an RGBA
|
||||
|
@ -190,7 +190,7 @@ class PhotoImage:
|
|||
# BitmapImage
|
||||
|
||||
|
||||
class BitmapImage:
|
||||
class BitmapImage(object):
|
||||
"""
|
||||
|
||||
A Tkinter-compatible bitmap image. This can be used everywhere Tkinter
|
||||
|
|
|
@ -21,7 +21,7 @@ import warnings
|
|||
from PIL import Image
|
||||
|
||||
|
||||
class HDC:
|
||||
class HDC(object):
|
||||
"""
|
||||
Wraps an HDC integer. The resulting object can be passed to the
|
||||
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
|
||||
|
@ -34,7 +34,7 @@ class HDC:
|
|||
return self.dc
|
||||
|
||||
|
||||
class HWND:
|
||||
class HWND(object):
|
||||
"""
|
||||
Wraps an HWND integer. The resulting object can be passed to the
|
||||
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
|
||||
|
@ -47,7 +47,7 @@ class HWND:
|
|||
return self.wnd
|
||||
|
||||
|
||||
class Dib:
|
||||
class Dib(object):
|
||||
"""
|
||||
A Windows bitmap with the given mode and size. The mode can be one of "1",
|
||||
"L", "P", or "RGB".
|
||||
|
@ -206,7 +206,7 @@ class Dib:
|
|||
##
|
||||
# Create a Window with the given title size.
|
||||
|
||||
class Window:
|
||||
class Window(object):
|
||||
|
||||
def __init__(self, title="PIL", width=None, height=None):
|
||||
self.hwnd = Image.core.createwindow(
|
||||
|
|
|
@ -251,7 +251,7 @@ def getiptcinfo(im):
|
|||
return None # no properties
|
||||
|
||||
# create an IptcImagePlugin object without initializing it
|
||||
class FakeImage:
|
||||
class FakeImage(object):
|
||||
pass
|
||||
im = FakeImage()
|
||||
im.__class__ = IptcImageFile
|
||||
|
|
|
@ -22,7 +22,7 @@ from PIL._binary import i8
|
|||
#
|
||||
# Bitstream parser
|
||||
|
||||
class BitStream:
|
||||
class BitStream(object):
|
||||
|
||||
def __init__(self, fp):
|
||||
self.fp = fp
|
||||
|
|
|
@ -473,7 +473,7 @@ def filetime2datetime(filetime):
|
|||
|
||||
#=== CLASSES ==================================================================
|
||||
|
||||
class OleMetadata:
|
||||
class OleMetadata(object):
|
||||
"""
|
||||
class to parse and store metadata from standard properties of OLE files.
|
||||
|
||||
|
@ -757,7 +757,7 @@ class _OleStream(io.BytesIO):
|
|||
|
||||
#--- _OleDirectoryEntry -------------------------------------------------------
|
||||
|
||||
class _OleDirectoryEntry:
|
||||
class _OleDirectoryEntry(object):
|
||||
|
||||
"""
|
||||
OLE2 Directory Entry
|
||||
|
@ -1007,7 +1007,7 @@ class _OleDirectoryEntry:
|
|||
|
||||
#--- OleFileIO ----------------------------------------------------------------
|
||||
|
||||
class OleFileIO:
|
||||
class OleFileIO(object):
|
||||
"""
|
||||
OLE container object
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from PIL import EpsImagePlugin
|
|||
##
|
||||
# Simple Postscript graphics interface.
|
||||
|
||||
class PSDraw:
|
||||
class PSDraw(object):
|
||||
"""
|
||||
Sets up printing to the given file. If **file** is omitted,
|
||||
:py:attr:`sys.stdout` is assumed.
|
||||
|
|
|
@ -19,7 +19,7 @@ from PIL._binary import o8
|
|||
##
|
||||
# File handler for Teragon-style palette files.
|
||||
|
||||
class PaletteFile:
|
||||
class PaletteFile(object):
|
||||
|
||||
rawmode = "RGB"
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ def _save(im, fp, filename):
|
|||
|
||||
xref = [0]*(5+1) # placeholders
|
||||
|
||||
class TextWriter:
|
||||
class TextWriter(object):
|
||||
def __init__(self, fp):
|
||||
self.fp = fp
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ def _safe_zlib_decompress(s):
|
|||
# --------------------------------------------------------------------
|
||||
# Support classes. Suitable for PNG and related formats like MNG etc.
|
||||
|
||||
class ChunkStream:
|
||||
class ChunkStream(object):
|
||||
|
||||
def __init__(self, fp):
|
||||
|
||||
|
@ -183,7 +183,7 @@ class iTXt(str):
|
|||
return self
|
||||
|
||||
|
||||
class PngInfo:
|
||||
class PngInfo(object):
|
||||
"""
|
||||
PNG chunk container (for use with save(pnginfo=))
|
||||
|
||||
|
@ -620,7 +620,7 @@ def putchunk(fp, cid, *data):
|
|||
fp.write(o16(hi) + o16(lo))
|
||||
|
||||
|
||||
class _idat:
|
||||
class _idat(object):
|
||||
# wrap output from the encoder in IDAT chunks
|
||||
|
||||
def __init__(self, fp, chunk):
|
||||
|
@ -771,7 +771,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0):
|
|||
def getchunks(im, **params):
|
||||
"""Return a list of PNG chunks representing this image."""
|
||||
|
||||
class collector:
|
||||
class collector(object):
|
||||
data = []
|
||||
|
||||
def write(self, data):
|
||||
|
|
|
@ -37,7 +37,7 @@ def register_handler(handler):
|
|||
if hasattr(Image.core, "drawwmf"):
|
||||
# install default handler (windows only)
|
||||
|
||||
class WmfHandler:
|
||||
class WmfHandler(object):
|
||||
|
||||
def open(self, im):
|
||||
im.mode = "RGB"
|
||||
|
|
|
@ -13,7 +13,7 @@ import os
|
|||
import sys
|
||||
|
||||
|
||||
class Interval:
|
||||
class Interval(object):
|
||||
|
||||
def __init__(self, interval="0"):
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ from PIL.GifImagePlugin import getheader, getdata
|
|||
# sequence iterator
|
||||
|
||||
|
||||
class image_sequence:
|
||||
class image_sequence(object):
|
||||
def __init__(self, im):
|
||||
self.im = im
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ from __future__ import print_function
|
|||
from PIL import Image
|
||||
|
||||
|
||||
class PILDriver:
|
||||
class PILDriver(object):
|
||||
|
||||
verbose = 0
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class TestFileIptc(PillowTestCase):
|
|||
|
||||
def dummy_IptcImagePlugin(self):
|
||||
# Create an IptcImagePlugin object without initializing it
|
||||
class FakeImage:
|
||||
class FakeImage(object):
|
||||
pass
|
||||
im = FakeImage()
|
||||
im.__class__ = IptcImagePlugin.IptcImageFile
|
||||
|
|
|
@ -8,7 +8,7 @@ class TestImageFileIo(PillowTestCase):
|
|||
|
||||
def test_fileio(self):
|
||||
|
||||
class DumbFile:
|
||||
class DumbFile(object):
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ try:
|
|||
from PIL import ImageFont
|
||||
ImageFont.core.getfont # check if freetype is available
|
||||
|
||||
class SimplePatcher():
|
||||
class SimplePatcher(object):
|
||||
def __init__(self, parent_obj, attr_name, value):
|
||||
self._parent_obj = parent_obj
|
||||
self._attr_name = attr_name
|
||||
|
|
|
@ -5,7 +5,7 @@ from PIL import ImageOps
|
|||
|
||||
class TestImageOps(PillowTestCase):
|
||||
|
||||
class Deformer:
|
||||
class Deformer(object):
|
||||
def getmesh(self, im):
|
||||
x, y = im.size
|
||||
return [((0, 0, x, y), (0, 0, x, 0, x, y, y, 0))]
|
||||
|
|
Loading…
Reference in New Issue
Block a user