From 9d4b2bea5067c102eba62c26100c2d2d8b5c8845 Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares <3694604+villares@users.noreply.github.com> Date: Wed, 2 Sep 2020 00:24:48 -0300 Subject: [PATCH] Update helpers.py --- admin_scripts/helpers.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/admin_scripts/helpers.py b/admin_scripts/helpers.py index 7e110245..cc0c6f44 100644 --- a/admin_scripts/helpers.py +++ b/admin_scripts/helpers.py @@ -1,6 +1,7 @@ from os import listdir from os.path import isfile, join + def get_image_names(base, folder, word=None): """ Return a list of image names from a directory @@ -14,11 +15,12 @@ def get_image_names(base, folder, word=None): and word in f] return image_files + def is_img_ext(file_name): """ Return True if file_name ends with one of the valid_ext extensions. - """ + """ ext = file_name.split('.')[-1] valid_ext = ('jpg', 'png', @@ -30,20 +32,26 @@ def is_img_ext(file_name): ) return ext.lower() in valid_ext -def build_entry(image, year): + +def build_entry(image, year, kind='pyde'): """ Return a string with markdown formated for the sketch-a-day index page entry of image (for a certain year). - """ + """ name, ext = image.split('.') + lib = {'pyde': "[[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]", + 'flat': "[[Python + flat](https://xxyxyz.org/flat)]", + } + return """ --- ![{0}]({2}/{0}/{0}.{1}) -[{0}](https://github.com/villares/sketch-a-day/tree/master/{2}/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] -""".format(name, ext, year) +[{0}](https://github.com/villares/sketch-a-day/tree/master/{2}/{0}) {3} +""".format(name, ext, year, lib[kind]) + def remove_transparency(im, bg_colour=(255, 255, 255)): from PIL import Image @@ -62,4 +70,3 @@ def remove_transparency(im, bg_colour=(255, 255, 255)): else: return im -