From 5ee7041e2046be73107c4732bcce1d80df5b260d Mon Sep 17 00:00:00 2001 From: codl Date: Fri, 11 Aug 2017 20:29:48 +0200 Subject: [PATCH] separate each file compression into a subtask --- dodo.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/dodo.py b/dodo.py index 2e9a012..002d754 100644 --- a/dodo.py +++ b/dodo.py @@ -52,8 +52,7 @@ def task_compress_static(): import brotli import gzip - deps = ('static/styles.css', 'static/icon.png', 'static/logotype.png') + tuple((f'static/logotype-{width}.png' for width in (200, 400, 600, 800))) - targets = tuple((f'{file}.br' for file in deps)) + tuple((f'{file}.gz' for file in deps)) + files = ('static/styles.css', 'static/icon.png', 'static/logotype.png') + tuple((f'static/logotype-{width}.png' for width in (200, 400, 600, 800))) def compress_brotli(dependencies): for filename in dependencies: @@ -66,12 +65,21 @@ def task_compress_static(): with gzip.open(filename + '.gz', 'wb') as out: out.write(in_.read()) - return dict( - file_dep=deps, - targets=targets, - actions=[compress_brotli, compress_gzip], - clean=True, - ) + for filename in files: + yield dict( + file_dep=(filename,), + targets=(filename+'.br',), + name=filename+'.br', + actions=[compress_brotli], + clean=True, + ) + yield dict( + file_dep=(filename,), + targets=(filename+'.gz',), + name=filename+'.gz', + actions=[compress_gzip], + clean=True, + ) if __name__ == '__main__': import doit