Replaced strings with docstrings

This commit is contained in:
Andrew Murray 2019-02-03 15:58:24 +11:00
parent 3a41d6dc69
commit fbaf87ae03
5 changed files with 28 additions and 28 deletions

View File

@ -46,7 +46,7 @@ class FontFile(object):
return self.glyph[ix]
def compile(self):
"Create metrics and bitmap"
"""Create metrics and bitmap"""
if self.bitmap:
return
@ -93,7 +93,7 @@ class FontFile(object):
self.metrics[i] = d, dst, s
def save(self, filename):
"Save font"
"""Save font"""
self.compile()

View File

@ -115,7 +115,7 @@ class ImageFile(Image.Image):
raise SyntaxError("not identified by this driver")
def draft(self, mode, size):
"Set draft mode"
"""Set draft mode"""
pass
@ -125,7 +125,7 @@ class ImageFile(Image.Image):
return self.custom_mimetype or Image.MIME.get(self.format.upper())
def verify(self):
"Check file integrity"
"""Check file integrity"""
# raise exception if something's wrong. must be called
# directly after open, and closes file when finished.
@ -134,7 +134,7 @@ class ImageFile(Image.Image):
self.fp = None
def load(self):
"Load image data based on tile list"
"""Load image data based on tile list"""
pixel = Image.Image.load(self)
@ -317,7 +317,7 @@ class StubImageFile(ImageFile):
self.__dict__ = image.__dict__
def _load(self):
"(Hook) Find actual image loader."
"""(Hook) Find actual image loader."""
raise NotImplementedError(
"StubImageFile subclass must implement _load"
)

View File

@ -41,7 +41,7 @@ class Stat(object):
self.bands = list(range(len(self.h) // 256))
def __getattr__(self, id):
"Calculate missing attribute"
"""Calculate missing attribute"""
if id[:4] == "_get":
raise AttributeError(id)
# calculate missing attribute
@ -50,7 +50,7 @@ class Stat(object):
return v
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):
n = 255
@ -67,7 +67,7 @@ class Stat(object):
return v
def _getcount(self):
"Get total number of pixels in each layer"
"""Get total number of pixels in each layer"""
v = []
for i in range(0, len(self.h), 256):
@ -75,7 +75,7 @@ class Stat(object):
return v
def _getsum(self):
"Get sum of all pixels in each layer"
"""Get sum of all pixels in each layer"""
v = []
for i in range(0, len(self.h), 256):
@ -86,7 +86,7 @@ class Stat(object):
return v
def _getsum2(self):
"Get squared sum of all pixels in each layer"
"""Get squared sum of all pixels in each layer"""
v = []
for i in range(0, len(self.h), 256):
@ -97,7 +97,7 @@ class Stat(object):
return v
def _getmean(self):
"Get average pixel level for each layer"
"""Get average pixel level for each layer"""
v = []
for i in self.bands:
@ -105,7 +105,7 @@ class Stat(object):
return v
def _getmedian(self):
"Get median pixel level for each layer"
"""Get median pixel level for each layer"""
v = []
for i in self.bands:
@ -120,7 +120,7 @@ class Stat(object):
return v
def _getrms(self):
"Get RMS for each layer"
"""Get RMS for each layer"""
v = []
for i in self.bands:
@ -128,7 +128,7 @@ class Stat(object):
return v
def _getvar(self):
"Get variance for each layer"
"""Get variance for each layer"""
v = []
for i in self.bands:
@ -137,7 +137,7 @@ class Stat(object):
return v
def _getstddev(self):
"Get standard deviation for each layer"
"""Get standard deviation for each layer"""
v = []
for i in self.bands:

View File

@ -102,7 +102,7 @@ class ChunkStream(object):
self.queue = []
def read(self):
"Fetch a new chunk. Returns header information."
"""Fetch a new chunk. Returns header information."""
cid = None
if self.queue:
@ -134,13 +134,13 @@ class ChunkStream(object):
self.queue.append((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)
return getattr(self, "chunk_" + cid.decode('ascii'))(pos, length)
def crc(self, cid, data):
"Read and verify checksum"
"""Read and verify checksum"""
# Skip CRC checks for ancillary chunks if allowed to load truncated
# images
@ -160,7 +160,7 @@ class ChunkStream(object):
% cid)
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)
@ -614,7 +614,7 @@ class PngImageFile(ImageFile.ImageFile):
return self._text
def verify(self):
"Verify PNG file"
"""Verify PNG file"""
if self.fp is None:
raise RuntimeError("verify must be called directly after open")
@ -630,7 +630,7 @@ class PngImageFile(ImageFile.ImageFile):
self.fp = None
def load_prepare(self):
"internal: prepare to read PNG file"
"""internal: prepare to read PNG file"""
if self.info.get("interlace"):
self.decoderconfig = self.decoderconfig + (1,)
@ -638,7 +638,7 @@ class PngImageFile(ImageFile.ImageFile):
ImageFile.ImageFile.load_prepare(self)
def load_read(self, read_bytes):
"internal: read more image data"
"""internal: read more image data"""
while self.__idat == 0:
# end of chunk, skip forward to next one
@ -664,7 +664,7 @@ class PngImageFile(ImageFile.ImageFile):
return self.fp.read(read_bytes)
def load_end(self):
"internal: finished reading image data"
"""internal: finished reading image data"""
while True:
self.fp.read(4) # CRC

View File

@ -963,7 +963,7 @@ class TiffImageFile(ImageFile.ImageFile):
_close_exclusive_fp_after_loading = False
def _open(self):
"Open the first image in a TIFF file"
"""Open the first image in a TIFF file"""
# Header
ifh = self.fp.read(8)
@ -1020,7 +1020,7 @@ class TiffImageFile(ImageFile.ImageFile):
return self._is_animated
def seek(self, frame):
"Select a given frame as current image"
"""Select a given frame as current image"""
if not self._seek_check(frame):
return
self._seek(frame)
@ -1058,7 +1058,7 @@ class TiffImageFile(ImageFile.ImageFile):
self._setup()
def tell(self):
"Return the current frame number"
"""Return the current frame number"""
return self.__frame
@property
@ -1173,7 +1173,7 @@ class TiffImageFile(ImageFile.ImageFile):
return Image.Image.load(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:
raise IOError("Windows Media Photo files not yet supported")