本文整理汇总了Python中sorl.thumbnail.helpers.get_module_class函数的典型用法代码示例。如果您正苦于以下问题:Python get_module_class函数的具体用法?Python get_module_class怎么用?Python get_module_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_module_class函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
# portrait
name = 'portrait.jpg'
fn = pjoin(settings.MEDIA_ROOT, name)
im = Image.new('L', (100, 200))
im.paste(255, (0, 0, 100, 100))
im.save(fn)
self.portrait = ImageFile(Item.objects.get_or_create(image=name)[0].image)
self.kvstore.delete(self.portrait)
# landscape
name = 'landscape.jpg'
fn = pjoin(settings.MEDIA_ROOT, name)
im = Image.new('L', (200, 100))
im.paste(255, (0, 0, 100, 100))
im.save(fn)
self.landscape = ImageFile(Item.objects.get_or_create(image=name)[0].image)
self.kvstore.delete(self.landscape)
示例2: setUp
def setUp(self):
self.BACKEND = get_module_class(settings.THUMBNAIL_BACKEND)()
self.ENGINE = get_module_class(settings.THUMBNAIL_ENGINE)()
self.KVSTORE = get_module_class(settings.THUMBNAIL_KVSTORE)()
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
shutil.copytree(settings.DATA_ROOT, DATA_DIR)
for dimension in self.IMAGE_DIMENSIONS:
name = '%sx%s.jpg' % dimension
self.create_image(name, dimension)
示例3: setUp
def setUp(self):
self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
dims = [(500, 500), (100, 100)]
for dim in dims:
name = "%sx%s.jpg" % dim
fn = pjoin(settings.MEDIA_ROOT, name)
im = Image.new("L", dim)
im.save(fn)
Item.objects.get_or_create(image=name)
示例4: setUp
def setUp(self):
self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
shutil.copytree(settings.DATA_ROOT, DATA_DIR)
dims = [(500, 500), (100, 100), (200, 100), ]
for dim in dims:
name = '%sx%s.jpg' % dim
self.create_image(name, dim)
示例5: test_dummy_response
def test_dummy_response(self):
client = Client()
response = client.get('/thumbnail-dummy/111x666/')
engine = get_module_class(settings.THUMBNAIL_ENGINE)()
image = engine.dummy_image(111, 666)
raw_data = engine._get_raw_data(image, format_='PNG', quality=95)
self.assertEqual(response.content, raw_data)
示例6: _setup
def _setup(self):
self._wrapped = get_module_class(settings.THUMBNAIL_BACKEND)()
示例7: _setup
def _setup(self):
self._wrapped = get_module_class(data['storage'])()
示例8: setUp
def setUp(self):
self.ENGINE = get_module_class(settings.THUMBNAIL_ENGINE)()
示例9: test_encode_utf8_filenames
def test_encode_utf8_filenames(self):
storage = get_module_class('sorl.thumbnail.images.UrlStorage')()
self.assertEqual(
storage.normalize_url('El jovencito emponzoñado de whisky, qué figura exhibe'),
'El%20jovencito%20emponzoado%20de%20whisky%2C%20qu%20figura%20exhibe'
)
示例10: setUp
def setUp(self):
self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
setattr(settings, "THUMBNAIL_DUMMY", True)
示例11: type
# coding: utf-8
from django.conf import settings
from sorl.thumbnail.helpers import get_module_class
engines = [get_module_class(engine_path)
for engine_path in settings.SORL_ENGINES]
EngineMixin = type('EngineMixin', tuple(engines), {})