doit: split off more tasks

This commit is contained in:
codl 2017-08-11 21:26:17 +02:00
parent 5147b7e3ff
commit 453e51c92f
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 24 additions and 22 deletions

46
dodo.py
View File

@ -3,33 +3,35 @@ def task_gen_logo():
from PIL import Image from PIL import Image
widths = (200, 400, 600, 800) def resize_logo(width):
def gen_logo():
with Image.open('assets/logotype.png') as im: with Image.open('assets/logotype.png') as im:
im = im.convert('L') im = im.convert('L')
for width in widths: height = im.height * width // im.width
height = im.height * width // im.width new = im.resize((width,height), resample=Image.LANCZOS)
new = im.resize((width,height), resample=Image.LANCZOS) new.save('static/logotype-{}.png'.format(width), optimize=True)
new.save('static/logotype-{}.png'.format(width), optimize=True)
im.save('static/logotype.png', optimize=True)
return dict( widths = (200, 400, 600, 800)
actions=[gen_logo], for width in widths:
targets=[f'static/logotype-{width}.png' for width in widths] yield dict(
+ ['static/logotype.png'], name=str(width),
file_dep=['assets/logotype.png'], actions=[(gen_logo, (width,))],
clean=True, targets=[f'static/logotype-{width}.png'],
) file_dep=['assets/logotype.png'],
clean=True,
)
def task_copy_icon():
def task_copy_asset():
import shutil import shutil
return dict( assets = ('icon.png', 'logotype.png')
actions=[lambda: shutil.copy('assets/icon.png', 'static/icon.png')], for asset in assets:
targets=['static/icon.png'], yield dict(
file_dep=['assets/icon.png'], name=asset,
clean=True, actions=[lambda: shutil.copy(f'assets/{asset}', f'static/{asset}')],
) targets=[f'static/{asset}'],
file_dep=[f'assets/{asset}'],
clean=True,
)
def task_minify_css(): def task_minify_css():
"""minify css""" """minify css"""