|
|
|
|
|
|
|
|
|
|
|
|
|
|
from jinja2 import Environment, PackageLoader, select_autoescape |
|
|
from jinja2 import Environment, PackageLoader, select_autoescape |
|
|
from PIL import Image, ExifTags |
|
|
from PIL import Image, ExifTags |
|
|
|
|
|
from dotenv import load_dotenv |
|
|
|
|
|
|
|
|
from configuration import SITE_TITLE, SITE_AUTHOR, SITE_AUTHOR_WEBSITE, THEME |
|
|
from configuration import SITE_TITLE, SITE_AUTHOR, SITE_AUTHOR_WEBSITE, THEME |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load env var from .env file |
|
|
|
|
|
load_dotenv(dotenv_path=".env") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PICTURES_DIR_NAME = "photos" |
|
|
PICTURES_DIR_NAME = "photos" |
|
|
OUTPUT_DIR_NAME = "output" |
|
|
OUTPUT_DIR_NAME = "output" |
|
|
|
|
|
|
|
|
|
|
|
# Configure YAML to accept environment variables in metadata files |
|
|
|
|
|
# Based on https://stackoverflow.com/a/27232341 solution |
|
|
|
|
|
pattern = re.compile(r"^ENV\[\'(.*)\'\]$") |
|
|
|
|
|
yaml.add_implicit_resolver("!pathex", pattern) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pathex_constructor(loader, node): |
|
|
|
|
|
value = loader.construct_scalar(node) |
|
|
|
|
|
env_var, = pattern.match(value).groups() |
|
|
|
|
|
return os.getenv(env_var) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yaml.add_constructor("!pathex", pathex_constructor) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def list_galleries_in(path): |
|
|
def list_galleries_in(path): |
|
|
gallery_dirs = [f for f in os.scandir(path) if f.is_dir()] |
|
|
gallery_dirs = [f for f in os.scandir(path) if f.is_dir()] |