2
0
mirror of https://github.com/codl/forget synced 2024-12-29 08:30:38 +01:00

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

46
dodo.py
View File

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