separate each file compression into a subtask
This commit is contained in:
parent
0cfdb90efd
commit
5ee7041e20
24
dodo.py
24
dodo.py
|
@ -52,8 +52,7 @@ def task_compress_static():
|
||||||
import brotli
|
import brotli
|
||||||
import gzip
|
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)))
|
files = ('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))
|
|
||||||
|
|
||||||
def compress_brotli(dependencies):
|
def compress_brotli(dependencies):
|
||||||
for filename in dependencies:
|
for filename in dependencies:
|
||||||
|
@ -66,12 +65,21 @@ def task_compress_static():
|
||||||
with gzip.open(filename + '.gz', 'wb') as out:
|
with gzip.open(filename + '.gz', 'wb') as out:
|
||||||
out.write(in_.read())
|
out.write(in_.read())
|
||||||
|
|
||||||
return dict(
|
for filename in files:
|
||||||
file_dep=deps,
|
yield dict(
|
||||||
targets=targets,
|
file_dep=(filename,),
|
||||||
actions=[compress_brotli, compress_gzip],
|
targets=(filename+'.br',),
|
||||||
clean=True,
|
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__':
|
if __name__ == '__main__':
|
||||||
import doit
|
import doit
|
||||||
|
|
Loading…
Reference in New Issue