Delayed import error for doc use

This commit is contained in:
wiredfool 2014-04-02 20:09:04 -07:00
parent b6955fcf15
commit 90bbd9ff3e
2 changed files with 13 additions and 1 deletions

View File

@ -84,7 +84,13 @@ VERSION = "1.0.0 pil"
# --------------------------------------------------------------------.
from PIL import Image
from PIL import _imagingcms
try:
from PIL import _imagingcms
except ImportError:
# Allow error import for doc purposes, but error out when accessing
# anything in core.
from _util import import_err
_imagingcms = import_err('ImagingCMS')
from PIL._util import isStringType
core = _imagingcms

View File

@ -14,3 +14,9 @@ else:
# Checks if an object is a string, and that it points to a directory.
def isDirectory(f):
return isPath(f) and os.path.isdir(f)
class import_err(object):
def __init__(self, name=''):
self.name = name
def __getattr__(self, elt):
raise Exception("Import Error, %s not available" % self.name)