kopia lustrzana https://github.com/villares/sketch-a-day
Update helpers.py
rodzic
6fb2d9f4ec
commit
9d4b2bea50
|
|
@ -1,6 +1,7 @@
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
|
|
||||||
def get_image_names(base, folder, word=None):
|
def get_image_names(base, folder, word=None):
|
||||||
"""
|
"""
|
||||||
Return a list of image names from a directory
|
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]
|
and word in f]
|
||||||
return image_files
|
return image_files
|
||||||
|
|
||||||
|
|
||||||
def is_img_ext(file_name):
|
def is_img_ext(file_name):
|
||||||
"""
|
"""
|
||||||
Return True if file_name ends with
|
Return True if file_name ends with
|
||||||
one of the valid_ext extensions.
|
one of the valid_ext extensions.
|
||||||
"""
|
"""
|
||||||
ext = file_name.split('.')[-1]
|
ext = file_name.split('.')[-1]
|
||||||
valid_ext = ('jpg',
|
valid_ext = ('jpg',
|
||||||
'png',
|
'png',
|
||||||
|
|
@ -30,20 +32,26 @@ def is_img_ext(file_name):
|
||||||
)
|
)
|
||||||
return ext.lower() in valid_ext
|
return ext.lower() in valid_ext
|
||||||
|
|
||||||
def build_entry(image, year):
|
|
||||||
|
def build_entry(image, year, kind='pyde'):
|
||||||
"""
|
"""
|
||||||
Return a string with markdown formated
|
Return a string with markdown formated
|
||||||
for the sketch-a-day index page entry
|
for the sketch-a-day index page entry
|
||||||
of image (for a certain year).
|
of image (for a certain year).
|
||||||
"""
|
"""
|
||||||
name, ext = image.split('.')
|
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 """
|
return """
|
||||||
---
|
---
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
[{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)]
|
[{0}](https://github.com/villares/sketch-a-day/tree/master/{2}/{0}) {3}
|
||||||
""".format(name, ext, year)
|
""".format(name, ext, year, lib[kind])
|
||||||
|
|
||||||
|
|
||||||
def remove_transparency(im, bg_colour=(255, 255, 255)):
|
def remove_transparency(im, bg_colour=(255, 255, 255)):
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
@ -62,4 +70,3 @@ def remove_transparency(im, bg_colour=(255, 255, 255)):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue