mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 19:06:18 +03:00
Replaced strings with docstrings
This commit is contained in:
parent
3a41d6dc69
commit
fbaf87ae03
|
@ -46,7 +46,7 @@ class FontFile(object):
|
||||||
return self.glyph[ix]
|
return self.glyph[ix]
|
||||||
|
|
||||||
def compile(self):
|
def compile(self):
|
||||||
"Create metrics and bitmap"
|
"""Create metrics and bitmap"""
|
||||||
|
|
||||||
if self.bitmap:
|
if self.bitmap:
|
||||||
return
|
return
|
||||||
|
@ -93,7 +93,7 @@ class FontFile(object):
|
||||||
self.metrics[i] = d, dst, s
|
self.metrics[i] = d, dst, s
|
||||||
|
|
||||||
def save(self, filename):
|
def save(self, filename):
|
||||||
"Save font"
|
"""Save font"""
|
||||||
|
|
||||||
self.compile()
|
self.compile()
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class ImageFile(Image.Image):
|
||||||
raise SyntaxError("not identified by this driver")
|
raise SyntaxError("not identified by this driver")
|
||||||
|
|
||||||
def draft(self, mode, size):
|
def draft(self, mode, size):
|
||||||
"Set draft mode"
|
"""Set draft mode"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class ImageFile(Image.Image):
|
||||||
return self.custom_mimetype or Image.MIME.get(self.format.upper())
|
return self.custom_mimetype or Image.MIME.get(self.format.upper())
|
||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
"Check file integrity"
|
"""Check file integrity"""
|
||||||
|
|
||||||
# raise exception if something's wrong. must be called
|
# raise exception if something's wrong. must be called
|
||||||
# directly after open, and closes file when finished.
|
# directly after open, and closes file when finished.
|
||||||
|
@ -134,7 +134,7 @@ class ImageFile(Image.Image):
|
||||||
self.fp = None
|
self.fp = None
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
"Load image data based on tile list"
|
"""Load image data based on tile list"""
|
||||||
|
|
||||||
pixel = Image.Image.load(self)
|
pixel = Image.Image.load(self)
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ class StubImageFile(ImageFile):
|
||||||
self.__dict__ = image.__dict__
|
self.__dict__ = image.__dict__
|
||||||
|
|
||||||
def _load(self):
|
def _load(self):
|
||||||
"(Hook) Find actual image loader."
|
"""(Hook) Find actual image loader."""
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"StubImageFile subclass must implement _load"
|
"StubImageFile subclass must implement _load"
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Stat(object):
|
||||||
self.bands = list(range(len(self.h) // 256))
|
self.bands = list(range(len(self.h) // 256))
|
||||||
|
|
||||||
def __getattr__(self, id):
|
def __getattr__(self, id):
|
||||||
"Calculate missing attribute"
|
"""Calculate missing attribute"""
|
||||||
if id[:4] == "_get":
|
if id[:4] == "_get":
|
||||||
raise AttributeError(id)
|
raise AttributeError(id)
|
||||||
# calculate missing attribute
|
# calculate missing attribute
|
||||||
|
@ -50,7 +50,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getextrema(self):
|
def _getextrema(self):
|
||||||
"Get min/max values for each band in the image"
|
"""Get min/max values for each band in the image"""
|
||||||
|
|
||||||
def minmax(histogram):
|
def minmax(histogram):
|
||||||
n = 255
|
n = 255
|
||||||
|
@ -67,7 +67,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getcount(self):
|
def _getcount(self):
|
||||||
"Get total number of pixels in each layer"
|
"""Get total number of pixels in each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in range(0, len(self.h), 256):
|
for i in range(0, len(self.h), 256):
|
||||||
|
@ -75,7 +75,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getsum(self):
|
def _getsum(self):
|
||||||
"Get sum of all pixels in each layer"
|
"""Get sum of all pixels in each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in range(0, len(self.h), 256):
|
for i in range(0, len(self.h), 256):
|
||||||
|
@ -86,7 +86,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getsum2(self):
|
def _getsum2(self):
|
||||||
"Get squared sum of all pixels in each layer"
|
"""Get squared sum of all pixels in each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in range(0, len(self.h), 256):
|
for i in range(0, len(self.h), 256):
|
||||||
|
@ -97,7 +97,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getmean(self):
|
def _getmean(self):
|
||||||
"Get average pixel level for each layer"
|
"""Get average pixel level for each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in self.bands:
|
for i in self.bands:
|
||||||
|
@ -105,7 +105,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getmedian(self):
|
def _getmedian(self):
|
||||||
"Get median pixel level for each layer"
|
"""Get median pixel level for each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in self.bands:
|
for i in self.bands:
|
||||||
|
@ -120,7 +120,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getrms(self):
|
def _getrms(self):
|
||||||
"Get RMS for each layer"
|
"""Get RMS for each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in self.bands:
|
for i in self.bands:
|
||||||
|
@ -128,7 +128,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getvar(self):
|
def _getvar(self):
|
||||||
"Get variance for each layer"
|
"""Get variance for each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in self.bands:
|
for i in self.bands:
|
||||||
|
@ -137,7 +137,7 @@ class Stat(object):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _getstddev(self):
|
def _getstddev(self):
|
||||||
"Get standard deviation for each layer"
|
"""Get standard deviation for each layer"""
|
||||||
|
|
||||||
v = []
|
v = []
|
||||||
for i in self.bands:
|
for i in self.bands:
|
||||||
|
|
|
@ -102,7 +102,7 @@ class ChunkStream(object):
|
||||||
self.queue = []
|
self.queue = []
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
"Fetch a new chunk. Returns header information."
|
"""Fetch a new chunk. Returns header information."""
|
||||||
cid = None
|
cid = None
|
||||||
|
|
||||||
if self.queue:
|
if self.queue:
|
||||||
|
@ -134,13 +134,13 @@ class ChunkStream(object):
|
||||||
self.queue.append((cid, pos, length))
|
self.queue.append((cid, pos, length))
|
||||||
|
|
||||||
def call(self, cid, pos, length):
|
def call(self, cid, pos, length):
|
||||||
"Call the appropriate chunk handler"
|
"""Call the appropriate chunk handler"""
|
||||||
|
|
||||||
logger.debug("STREAM %r %s %s", cid, pos, length)
|
logger.debug("STREAM %r %s %s", cid, pos, length)
|
||||||
return getattr(self, "chunk_" + cid.decode('ascii'))(pos, length)
|
return getattr(self, "chunk_" + cid.decode('ascii'))(pos, length)
|
||||||
|
|
||||||
def crc(self, cid, data):
|
def crc(self, cid, data):
|
||||||
"Read and verify checksum"
|
"""Read and verify checksum"""
|
||||||
|
|
||||||
# Skip CRC checks for ancillary chunks if allowed to load truncated
|
# Skip CRC checks for ancillary chunks if allowed to load truncated
|
||||||
# images
|
# images
|
||||||
|
@ -160,7 +160,7 @@ class ChunkStream(object):
|
||||||
% cid)
|
% cid)
|
||||||
|
|
||||||
def crc_skip(self, cid, data):
|
def crc_skip(self, cid, data):
|
||||||
"Read checksum. Used if the C module is not present"
|
"""Read checksum. Used if the C module is not present"""
|
||||||
|
|
||||||
self.fp.read(4)
|
self.fp.read(4)
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
return self._text
|
return self._text
|
||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
"Verify PNG file"
|
"""Verify PNG file"""
|
||||||
|
|
||||||
if self.fp is None:
|
if self.fp is None:
|
||||||
raise RuntimeError("verify must be called directly after open")
|
raise RuntimeError("verify must be called directly after open")
|
||||||
|
@ -630,7 +630,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
self.fp = None
|
self.fp = None
|
||||||
|
|
||||||
def load_prepare(self):
|
def load_prepare(self):
|
||||||
"internal: prepare to read PNG file"
|
"""internal: prepare to read PNG file"""
|
||||||
|
|
||||||
if self.info.get("interlace"):
|
if self.info.get("interlace"):
|
||||||
self.decoderconfig = self.decoderconfig + (1,)
|
self.decoderconfig = self.decoderconfig + (1,)
|
||||||
|
@ -638,7 +638,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
ImageFile.ImageFile.load_prepare(self)
|
ImageFile.ImageFile.load_prepare(self)
|
||||||
|
|
||||||
def load_read(self, read_bytes):
|
def load_read(self, read_bytes):
|
||||||
"internal: read more image data"
|
"""internal: read more image data"""
|
||||||
|
|
||||||
while self.__idat == 0:
|
while self.__idat == 0:
|
||||||
# end of chunk, skip forward to next one
|
# end of chunk, skip forward to next one
|
||||||
|
@ -664,7 +664,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
return self.fp.read(read_bytes)
|
return self.fp.read(read_bytes)
|
||||||
|
|
||||||
def load_end(self):
|
def load_end(self):
|
||||||
"internal: finished reading image data"
|
"""internal: finished reading image data"""
|
||||||
while True:
|
while True:
|
||||||
self.fp.read(4) # CRC
|
self.fp.read(4) # CRC
|
||||||
|
|
||||||
|
|
|
@ -963,7 +963,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
_close_exclusive_fp_after_loading = False
|
_close_exclusive_fp_after_loading = False
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
"Open the first image in a TIFF file"
|
"""Open the first image in a TIFF file"""
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
ifh = self.fp.read(8)
|
ifh = self.fp.read(8)
|
||||||
|
@ -1020,7 +1020,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
return self._is_animated
|
return self._is_animated
|
||||||
|
|
||||||
def seek(self, frame):
|
def seek(self, frame):
|
||||||
"Select a given frame as current image"
|
"""Select a given frame as current image"""
|
||||||
if not self._seek_check(frame):
|
if not self._seek_check(frame):
|
||||||
return
|
return
|
||||||
self._seek(frame)
|
self._seek(frame)
|
||||||
|
@ -1058,7 +1058,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
self._setup()
|
self._setup()
|
||||||
|
|
||||||
def tell(self):
|
def tell(self):
|
||||||
"Return the current frame number"
|
"""Return the current frame number"""
|
||||||
return self.__frame
|
return self.__frame
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1173,7 +1173,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
return Image.Image.load(self)
|
return Image.Image.load(self)
|
||||||
|
|
||||||
def _setup(self):
|
def _setup(self):
|
||||||
"Setup this image object based on current tags"
|
"""Setup this image object based on current tags"""
|
||||||
|
|
||||||
if 0xBC01 in self.tag_v2:
|
if 0xBC01 in self.tag_v2:
|
||||||
raise IOError("Windows Media Photo files not yet supported")
|
raise IOError("Windows Media Photo files not yet supported")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user