From a153812add3f745e8de39630de509ee9b1dd54c6 Mon Sep 17 00:00:00 2001 From: Yuri Kanivetsky Date: Tue, 29 Aug 2017 11:27:10 +0300 Subject: [PATCH 1/2] generateimages: fix taking arguments --- imagekit/management/commands/generateimages.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imagekit/management/commands/generateimages.py b/imagekit/management/commands/generateimages.py index 0d9cae5..4983af3 100644 --- a/imagekit/management/commands/generateimages.py +++ b/imagekit/management/commands/generateimages.py @@ -12,13 +12,15 @@ segments. (Segments are separated with colons.) So, for example, "a:*:c" will match "a:b:c", but not "a:b:x:c", whereas "a:**:c" will match both. Subsegments are always matched, so "a" will match "a" as well as "a:b" and "a:b:c".""") - args = '[generator_ids]' + + def add_arguments(self, parser): + parser.add_argument('generator_id', nargs='*', help=':: for model specs') def handle(self, *args, **options): generators = generator_registry.get_ids() - if args: - patterns = self.compile_patterns(args) + if options['generator_id']: + patterns = self.compile_patterns(options['generator_id']) generators = (id for id in generators if any(p.match(id) for p in patterns)) for generator_id in generators: From de3047e73d813ec9a2e96381a3bda5a2cf19cd78 Mon Sep 17 00:00:00 2001 From: Yuri Kanivetsky Date: Tue, 12 Sep 2017 20:44:22 +0300 Subject: [PATCH 2/2] Make generateimages support pre Django 1.8 versions --- imagekit/management/commands/generateimages.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imagekit/management/commands/generateimages.py b/imagekit/management/commands/generateimages.py index 4983af3..2addfd3 100644 --- a/imagekit/management/commands/generateimages.py +++ b/imagekit/management/commands/generateimages.py @@ -12,6 +12,7 @@ segments. (Segments are separated with colons.) So, for example, "a:*:c" will match "a:b:c", but not "a:b:x:c", whereas "a:**:c" will match both. Subsegments are always matched, so "a" will match "a" as well as "a:b" and "a:b:c".""") + args = '[generator_ids]' def add_arguments(self, parser): parser.add_argument('generator_id', nargs='*', help=':: for model specs') @@ -19,8 +20,9 @@ well as "a:b" and "a:b:c".""") def handle(self, *args, **options): generators = generator_registry.get_ids() - if options['generator_id']: - patterns = self.compile_patterns(options['generator_id']) + generator_ids = options['generator_id'] if 'generator_id' in options else args + if generator_ids: + patterns = self.compile_patterns(generator_ids) generators = (id for id in generators if any(p.match(id) for p in patterns)) for generator_id in generators: