flake8 and fix path in __main__

This commit is contained in:
hugovk 2014-07-05 01:02:46 +03:00
parent ff6a0b9b8c
commit 770ef9312b

View File

@ -29,13 +29,15 @@ from __future__ import print_function
from PIL import Image
from PIL._util import isDirectory, isPath
import os, sys
import os
import sys
try:
import warnings
except ImportError:
warnings = None
class _imagingft_not_installed:
# module placeholder
def __getattr__(self, id):
@ -90,7 +92,7 @@ class ImageFont:
# read PILfont header
if file.readline() != b"PILfont\n":
raise SyntaxError("Not a PILfont file")
d = file.readline().split(b";")
file.readline().split(b";")
self.info = [] # FIXME: should be a dictionary
while True:
s = file.readline()
@ -113,6 +115,7 @@ class ImageFont:
self.getsize = self.font.getsize
self.getmask = self.font.getmask
##
# Wrapper for FreeType fonts. Application code should use the
# <b>truetype</b> factory function to create font objects.
@ -124,14 +127,18 @@ class FreeTypeFont:
# FIXME: use service provider instead
if file:
if warnings:
warnings.warn('file parameter deprecated, please use font parameter instead.', DeprecationWarning)
warnings.warn(
'file parameter deprecated, '
'please use font parameter instead.',
DeprecationWarning)
font = file
if isPath(font):
self.font = core.getfont(font, size, index, encoding)
else:
self.font_bytes = font.read()
self.font = core.getfont("", size, index, encoding, self.font_bytes)
self.font = core.getfont(
"", size, index, encoding, self.font_bytes)
def getname(self):
return self.font.family, self.font.style
@ -163,6 +170,7 @@ class FreeTypeFont:
# be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM,
# Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.
class TransposedFont:
"Wrapper for writing rotated or mirrored text"
@ -221,7 +229,10 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
if filename:
if warnings:
warnings.warn('filename parameter deprecated, please use font parameter instead.', DeprecationWarning)
warnings.warn(
'filename parameter deprecated, '
'please use font parameter instead.',
DeprecationWarning)
font = filename
try:
@ -395,8 +406,8 @@ w7IkEbzhVQAAAABJRU5ErkJggg==
if __name__ == "__main__":
# create font data chunk for embedding
import base64, os, sys
font = "../Tests/images/courB08"
import base64
font = "Tests/images/courB08"
print(" f._load_pilfont_data(")
print(" # %s" % os.path.basename(font))
print(" BytesIO(base64.decodestring(b'''")