Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(3)  |  Derive(0)  |  Import(2)
Returns the Image class for the specified backend

Handy in cases where you wish to make this configurable at runtime

Callers must be prepared to handle ImportErrors when a given backend
cannot be loaded and KeyError when an unknown backend is requested

        def get_image_class(backend):
    """
    Returns the Image class for the specified backend

    Handy in cases where you wish to make this configurable at runtime

    Callers must be prepared to handle ImportErrors when a given backend
    cannot be loaded and KeyError when an unknown backend is requested
    """

    if backend == "aware":
        from backends.aware import AwareImage
        return AwareImage
    if backend == "aware_cext":
        from backends.aware_cext import AwareImage
        return AwareImage
    elif backend.lower() == "graphicsmagick":
        from backends.GraphicsMagick import GraphicsMagickImage
        return GraphicsMagickImage
    elif backend.lower() == "java":
        from backends.java import JavaImage
        return JavaImage
    elif backend.lower() == "pil":
        # Useful only for benchmarking:
        from PIL import Image
        return Image
    else:
        raise KeyError("Unknown backend %s" % backend)
        


src/c/h/chronam-HEAD/core/views/image.py   chronam(Download)
    for backend in ('aware_cext', 'aware', 'graphicsmagick'):
        try:
            Image = NativeImaging.get_image_class(backend)
            break
        except ImportError, e:

src/n/a/NativeImaging-HEAD/tests/test_pil.py   NativeImaging(Download)
import unittest
 
from api import ApiConformanceTests
 
from NativeImaging import get_image_class
 
class PILTests(ApiConformanceTests, unittest.TestCase):
    IMAGE_CLASS = get_image_class("PIL")

src/n/a/NativeImaging-HEAD/tests/resize-bench.py   NativeImaging(Download)
import tempfile
 
from NativeImaging import get_image_class
 
 
    for backend_name in backend_names:
        try:
            backends[backend_name] = get_image_class(backend_name)
        except (ImportError, KeyError):
            print >> sys.stderr, "Can't load %s backend" % backend_name