From 5a1dd0c459a32c57dc05b6872d92f83c2fe5f6e0 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Thu, 4 Oct 2012 23:27:19 -0400 Subject: [PATCH] Don't require spec to be created up-front --- imagekit/specs.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/imagekit/specs.py b/imagekit/specs.py index 49affad..2d4b400 100644 --- a/imagekit/specs.py +++ b/imagekit/specs.py @@ -176,21 +176,22 @@ class SpecHost(object): storage=None, autoconvert=None, image_cache_backend=None, image_cache_strategy=None, spec=None, spec_id=None): - if spec: - if any([processors, format, options, storage, autoconvert, - image_cache_backend, image_cache_strategy]): + spec_args = dict( + processors=processors, + format=format, + options=options, + storage=storage, + autoconvert=autoconvert, + image_cache_backend=image_cache_backend, + image_cache_strategy=image_cache_strategy, + ) + + if any(v is not None for v in spec_args.values()): + if spec: raise TypeError('You can provide either an image spec or' ' arguments for the ImageSpec constructor, but not both.') - else: - spec = ImageSpec( - processors=processors, - format=format, - options=options, - storage=storage, - autoconvert=autoconvert, - image_cache_backend=image_cache_backend, - image_cache_strategy=image_cache_strategy, - ) + else: + spec = ImageSpec(**spec_args) self._original_spec = spec