From ea3be60c034e409635caa944f82d9598a7ca808d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 24 Sep 2016 19:10:46 +1000 Subject: [PATCH] Converted documentation --- PIL/BufrStubImagePlugin.py | 10 ++--- PIL/ContainerIO.py | 76 +++++++++++++++++++------------------- PIL/FitsStubImagePlugin.py | 10 ++--- PIL/GdImageFile.py | 17 ++++----- PIL/GribStubImagePlugin.py | 10 ++--- PIL/Hdf5StubImagePlugin.py | 10 ++--- PIL/ImageFont.py | 18 ++++----- PIL/ImageQt.py | 21 ++++++----- PIL/IptcImagePlugin.py | 13 +++---- PIL/TarIO.py | 11 +++--- PIL/WalImageFile.py | 18 ++++----- PIL/WmfImagePlugin.py | 10 ++--- 12 files changed, 111 insertions(+), 113 deletions(-) diff --git a/PIL/BufrStubImagePlugin.py b/PIL/BufrStubImagePlugin.py index 45ee54776..5184546e4 100644 --- a/PIL/BufrStubImagePlugin.py +++ b/PIL/BufrStubImagePlugin.py @@ -14,12 +14,12 @@ from PIL import Image, ImageFile _handler = None -## -# Install application-specific BUFR image handler. -# -# @param handler Handler object. - def register_handler(handler): + """ + Install application-specific BUFR image handler. + + :param handler: Handler object. + """ global _handler _handler = handler diff --git a/PIL/ContainerIO.py b/PIL/ContainerIO.py index 262f2afb9..609aa33e3 100644 --- a/PIL/ContainerIO.py +++ b/PIL/ContainerIO.py @@ -21,14 +21,14 @@ class ContainerIO(object): - ## - # Create file object. - # - # @param file Existing file. - # @param offset Start of region, in bytes. - # @param length Size of region, in bytes. - def __init__(self, file, offset, length): + """ + Create file object. + + :param file: Existing file. + :param offset: Start of region, in bytes. + :param length: Size of region, in bytes. + """ self.fh = file self.pos = 0 self.offset = offset @@ -41,15 +41,15 @@ class ContainerIO(object): def isatty(self): return 0 - ## - # Move file pointer. - # - # @param offset Offset in bytes. - # @param mode Starting position. Use 0 for beginning of region, 1 - # for current offset, and 2 for end of region. You cannot move - # the pointer outside the defined region. - def seek(self, offset, mode=0): + """ + Move file pointer. + + :param offset: Offset in bytes. + :param mode: Starting position. Use 0 for beginning of region, 1 + for current offset, and 2 for end of region. You cannot move + the pointer outside the defined region. + """ if mode == 1: self.pos = self.pos + offset elif mode == 2: @@ -60,23 +60,23 @@ class ContainerIO(object): self.pos = max(0, min(self.pos, self.length)) self.fh.seek(self.offset + self.pos) - ## - # Get current file pointer. - # - # @return Offset from start of region, in bytes. - def tell(self): + """ + Get current file pointer. + + :returns: Offset from start of region, in bytes. + """ return self.pos - ## - # Read data. - # - # @def read(bytes=0) - # @param bytes Number of bytes to read. If omitted or zero, - # read until end of region. - # @return An 8-bit string. - def read(self, n=0): + """ + Read data. + + @def read(bytes=0) + :param bytes: Number of bytes to read. If omitted or zero, + read until end of region. + :returns: An 8-bit string. + """ if n: n = min(n, self.length - self.pos) else: @@ -86,12 +86,12 @@ class ContainerIO(object): self.pos = self.pos + n return self.fh.read(n) - ## - # Read a line of text. - # - # @return An 8-bit string. - def readline(self): + """ + Read a line of text. + + :returns: An 8-bit string. + """ s = "" while True: c = self.read(1) @@ -102,12 +102,12 @@ class ContainerIO(object): break return s - ## - # Read multiple lines of text. - # - # @return A list of 8-bit strings. - def readlines(self): + """ + Read multiple lines of text. + + :returns: A list of 8-bit strings. + """ l = [] while True: s = self.readline() diff --git a/PIL/FitsStubImagePlugin.py b/PIL/FitsStubImagePlugin.py index 7aefff212..b6ea0e37d 100644 --- a/PIL/FitsStubImagePlugin.py +++ b/PIL/FitsStubImagePlugin.py @@ -13,13 +13,13 @@ from PIL import Image, ImageFile _handler = None -## -# Install application-specific FITS image handler. -# -# @param handler Handler object. - def register_handler(handler): + """ + Install application-specific FITS image handler. + + :param handler: Handler object. + """ global _handler _handler = handler diff --git a/PIL/GdImageFile.py b/PIL/GdImageFile.py index ae3500f0c..5a07ee230 100644 --- a/PIL/GdImageFile.py +++ b/PIL/GdImageFile.py @@ -66,17 +66,16 @@ class GdImageFile(ImageFile.ImageFile): self.tile = [("raw", (0, 0)+self.size, 775, ("L", 0, -1))] -## -# Load texture from a GD image file. -# -# @param filename GD file name, or an opened file handle. -# @param mode Optional mode. In this version, if the mode argument -# is given, it must be "r". -# @return An image instance. -# @exception IOError If the image could not be read. - def open(fp, mode="r"): + """ + Load texture from a GD image file. + :param filename: GD file name, or an opened file handle. + :param mode: Optional mode. In this version, if the mode argument + is given, it must be "r". + :returns: An image instance. + :raises IOError: If the image could not be read. + """ if mode != "r": raise ValueError("bad mode") diff --git a/PIL/GribStubImagePlugin.py b/PIL/GribStubImagePlugin.py index 8ffad8100..e880e5281 100644 --- a/PIL/GribStubImagePlugin.py +++ b/PIL/GribStubImagePlugin.py @@ -14,12 +14,12 @@ from PIL import Image, ImageFile _handler = None -## -# Install application-specific GRIB image handler. -# -# @param handler Handler object. - def register_handler(handler): + """ + Install application-specific GRIB image handler. + + :param handler: Handler object. + """ global _handler _handler = handler diff --git a/PIL/Hdf5StubImagePlugin.py b/PIL/Hdf5StubImagePlugin.py index f7945be7e..dc85084d8 100644 --- a/PIL/Hdf5StubImagePlugin.py +++ b/PIL/Hdf5StubImagePlugin.py @@ -14,12 +14,12 @@ from PIL import Image, ImageFile _handler = None -## -# Install application-specific HDF5 image handler. -# -# @param handler Handler object. - def register_handler(handler): + """ + Install application-specific HDF5 image handler. + + :param handler: Handler object. + """ global _handler _handler = handler diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py index dc0343ca0..6bd48dd6e 100644 --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -169,20 +169,20 @@ class FreeTypeFont(object): encoding=self.encoding if encoding is None else encoding) -## -# Wrapper that creates a transposed font from any existing font -# object. -# -# @param font A font object. -# @param orientation An optional orientation. If given, this should -# be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM, -# Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270. - class TransposedFont(object): "Wrapper for writing rotated or mirrored text" def __init__(self, font, orientation=None): + """ + Wrapper that creates a transposed font from any existing font + object. + + :param font: A font object. + :param orientation: An optional orientation. If given, this should + be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM, + Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270. + """ self.font = font self.orientation = orientation # any 'transpose' argument, or None diff --git a/PIL/ImageQt.py b/PIL/ImageQt.py index 4eb365402..3f7ae2518 100644 --- a/PIL/ImageQt.py +++ b/PIL/ImageQt.py @@ -47,10 +47,11 @@ def rgb(r, g, b, a=255): return (qRgba(r, g, b, a) & 0xffffffff) -# :param im A PIL Image object, or a file name -# (given either as Python string or a PyQt string object) - def fromqimage(im): + """ + :param im: A PIL Image object, or a file name + (given either as Python string or a PyQt string object) + """ buffer = QBuffer() buffer.open(QIODevice.ReadWrite) # preserve alha channel with png @@ -162,17 +163,17 @@ def _toqclass_helper(im): 'data': __data, 'im': im, 'format': format, 'colortable': colortable } -## -# An PIL image wrapper for Qt. This is a subclass of PyQt's QImage -# class. -# -# @param im A PIL Image object, or a file name (given either as Python -# string or a PyQt string object). - if qt_is_installed: class ImageQt(QImage): def __init__(self, im): + """ + An PIL image wrapper for Qt. This is a subclass of PyQt's QImage + class. + + :param im: A PIL Image object, or a file name (given either as Python + string or a PyQt string object). + """ im_data = _toqclass_helper(im) QImage.__init__(self, im_data['data'], im_data['im'].size[0], diff --git a/PIL/IptcImagePlugin.py b/PIL/IptcImagePlugin.py index 56d1de424..ed3bf81b1 100644 --- a/PIL/IptcImagePlugin.py +++ b/PIL/IptcImagePlugin.py @@ -188,15 +188,14 @@ Image.register_open(IptcImageFile.format, IptcImageFile) Image.register_extension(IptcImageFile.format, ".iim") -## -# Get IPTC information from TIFF, JPEG, or IPTC file. -# -# @param im An image containing IPTC data. -# @return A dictionary containing IPTC information, or None if -# no IPTC information block was found. - def getiptcinfo(im): + """ + Get IPTC information from TIFF, JPEG, or IPTC file. + :param im: An image containing IPTC data. + :returns: A dictionary containing IPTC information, or None if + no IPTC information block was found. + """ from PIL import TiffImagePlugin, JpegImagePlugin import io diff --git a/PIL/TarIO.py b/PIL/TarIO.py index 4e5115b26..4f3182848 100644 --- a/PIL/TarIO.py +++ b/PIL/TarIO.py @@ -23,14 +23,13 @@ from PIL import ContainerIO class TarIO(ContainerIO.ContainerIO): - ## - # Create file object. - # - # @param tarfile Name of TAR file. - # @param file Name of member file. - def __init__(self, tarfile, file): + """ + Create file object. + :param tarfile: Name of TAR file. + :param file: Name of member file. + """ fh = open(tarfile, "rb") while True: diff --git a/PIL/WalImageFile.py b/PIL/WalImageFile.py index 0cbd1cae6..b0b1e684a 100644 --- a/PIL/WalImageFile.py +++ b/PIL/WalImageFile.py @@ -34,16 +34,16 @@ except ImportError: i32 = _binary.i32le -## -# Load texture from a Quake2 WAL texture file. -#

-# By default, a Quake2 standard palette is attached to the texture. -# To override the palette, use the putpalette method. -# -# @param filename WAL file name, or an opened file handle. -# @return An image instance. - def open(filename): + """ + Load texture from a Quake2 WAL texture file. + + By default, a Quake2 standard palette is attached to the texture. + To override the palette, use the putpalette method. + + :param filename: WAL file name, or an opened file handle. + :returns: An image instance. + """ # FIXME: modify to return a WalImageFile instance instead of # plain Image object ? diff --git a/PIL/WmfImagePlugin.py b/PIL/WmfImagePlugin.py index 3163210a8..9416035c0 100644 --- a/PIL/WmfImagePlugin.py +++ b/PIL/WmfImagePlugin.py @@ -25,12 +25,12 @@ if str != bytes: long = int -## -# Install application-specific WMF image handler. -# -# @param handler Handler object. - def register_handler(handler): + """ + Install application-specific WMF image handler. + + :param handler: Handler object. + """ global _handler _handler = handler