Converted documentation

This commit is contained in:
Andrew Murray 2016-09-24 19:10:46 +10:00
parent 54520b10ac
commit ea3be60c03
12 changed files with 111 additions and 113 deletions

View File

@ -14,12 +14,12 @@ from PIL import Image, ImageFile
_handler = None _handler = None
##
# Install application-specific BUFR image handler.
#
# @param handler Handler object.
def register_handler(handler): def register_handler(handler):
"""
Install application-specific BUFR image handler.
:param handler: Handler object.
"""
global _handler global _handler
_handler = handler _handler = handler

View File

@ -21,14 +21,14 @@
class ContainerIO(object): 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): 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.fh = file
self.pos = 0 self.pos = 0
self.offset = offset self.offset = offset
@ -41,15 +41,15 @@ class ContainerIO(object):
def isatty(self): def isatty(self):
return 0 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): 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: if mode == 1:
self.pos = self.pos + offset self.pos = self.pos + offset
elif mode == 2: elif mode == 2:
@ -60,23 +60,23 @@ class ContainerIO(object):
self.pos = max(0, min(self.pos, self.length)) self.pos = max(0, min(self.pos, self.length))
self.fh.seek(self.offset + self.pos) self.fh.seek(self.offset + self.pos)
##
# Get current file pointer.
#
# @return Offset from start of region, in bytes.
def tell(self): def tell(self):
"""
Get current file pointer.
:returns: Offset from start of region, in bytes.
"""
return self.pos 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): 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: if n:
n = min(n, self.length - self.pos) n = min(n, self.length - self.pos)
else: else:
@ -86,12 +86,12 @@ class ContainerIO(object):
self.pos = self.pos + n self.pos = self.pos + n
return self.fh.read(n) return self.fh.read(n)
##
# Read a line of text.
#
# @return An 8-bit string.
def readline(self): def readline(self):
"""
Read a line of text.
:returns: An 8-bit string.
"""
s = "" s = ""
while True: while True:
c = self.read(1) c = self.read(1)
@ -102,12 +102,12 @@ class ContainerIO(object):
break break
return s return s
##
# Read multiple lines of text.
#
# @return A list of 8-bit strings.
def readlines(self): def readlines(self):
"""
Read multiple lines of text.
:returns: A list of 8-bit strings.
"""
l = [] l = []
while True: while True:
s = self.readline() s = self.readline()

View File

@ -13,13 +13,13 @@ from PIL import Image, ImageFile
_handler = None _handler = None
##
# Install application-specific FITS image handler.
#
# @param handler Handler object.
def register_handler(handler): def register_handler(handler):
"""
Install application-specific FITS image handler.
:param handler: Handler object.
"""
global _handler global _handler
_handler = handler _handler = handler

View File

@ -66,17 +66,16 @@ class GdImageFile(ImageFile.ImageFile):
self.tile = [("raw", (0, 0)+self.size, 775, ("L", 0, -1))] 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"): 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": if mode != "r":
raise ValueError("bad mode") raise ValueError("bad mode")

View File

@ -14,12 +14,12 @@ from PIL import Image, ImageFile
_handler = None _handler = None
##
# Install application-specific GRIB image handler.
#
# @param handler Handler object.
def register_handler(handler): def register_handler(handler):
"""
Install application-specific GRIB image handler.
:param handler: Handler object.
"""
global _handler global _handler
_handler = handler _handler = handler

View File

@ -14,12 +14,12 @@ from PIL import Image, ImageFile
_handler = None _handler = None
##
# Install application-specific HDF5 image handler.
#
# @param handler Handler object.
def register_handler(handler): def register_handler(handler):
"""
Install application-specific HDF5 image handler.
:param handler: Handler object.
"""
global _handler global _handler
_handler = handler _handler = handler

View File

@ -169,20 +169,20 @@ class FreeTypeFont(object):
encoding=self.encoding if encoding is None else encoding=self.encoding if encoding is None else
encoding) 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): class TransposedFont(object):
"Wrapper for writing rotated or mirrored text" "Wrapper for writing rotated or mirrored text"
def __init__(self, font, orientation=None): 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.font = font
self.orientation = orientation # any 'transpose' argument, or None self.orientation = orientation # any 'transpose' argument, or None

View File

@ -47,10 +47,11 @@ def rgb(r, g, b, a=255):
return (qRgba(r, g, b, a) & 0xffffffff) 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): 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 = QBuffer()
buffer.open(QIODevice.ReadWrite) buffer.open(QIODevice.ReadWrite)
# preserve alha channel with png # preserve alha channel with png
@ -162,17 +163,17 @@ def _toqclass_helper(im):
'data': __data, 'im': im, 'format': format, 'colortable': colortable '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: if qt_is_installed:
class ImageQt(QImage): class ImageQt(QImage):
def __init__(self, im): 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) im_data = _toqclass_helper(im)
QImage.__init__(self, QImage.__init__(self,
im_data['data'], im_data['im'].size[0], im_data['data'], im_data['im'].size[0],

View File

@ -188,15 +188,14 @@ Image.register_open(IptcImageFile.format, IptcImageFile)
Image.register_extension(IptcImageFile.format, ".iim") 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): 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 from PIL import TiffImagePlugin, JpegImagePlugin
import io import io

View File

@ -23,14 +23,13 @@ from PIL import ContainerIO
class TarIO(ContainerIO.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): def __init__(self, tarfile, file):
"""
Create file object.
:param tarfile: Name of TAR file.
:param file: Name of member file.
"""
fh = open(tarfile, "rb") fh = open(tarfile, "rb")
while True: while True:

View File

@ -34,16 +34,16 @@ except ImportError:
i32 = _binary.i32le i32 = _binary.i32le
##
# Load texture from a Quake2 WAL texture file.
# <p>
# By default, a Quake2 standard palette is attached to the texture.
# To override the palette, use the <b>putpalette</b> method.
#
# @param filename WAL file name, or an opened file handle.
# @return An image instance.
def open(filename): 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 <b>putpalette</b> method.
:param filename: WAL file name, or an opened file handle.
:returns: An image instance.
"""
# FIXME: modify to return a WalImageFile instance instead of # FIXME: modify to return a WalImageFile instance instead of
# plain Image object ? # plain Image object ?

View File

@ -25,12 +25,12 @@ if str != bytes:
long = int long = int
##
# Install application-specific WMF image handler.
#
# @param handler Handler object.
def register_handler(handler): def register_handler(handler):
"""
Install application-specific WMF image handler.
:param handler: Handler object.
"""
global _handler global _handler
_handler = handler _handler = handler