#!/usr/bin/env python3 from os import path import textwrap import sys from typing import List import jinja2 ROOT = 'https://ethulhu.co.uk' TEMPLATE = ''' {% for url in urls -%} {{ root }}/{{ url.loc }} {% endfor %} '''.strip() def loc_from_path(p: str) -> str: basename, _ = path.splitext(p) return '/'.join(basename.split('/')[1:]) if __name__ == '__main__': paths = sys.argv[1:] urls = [{'loc': loc_from_path(p)} for p in paths if p.endswith('.html')] environment = jinja2.Environment( trim_blocks=True, ) print(environment.from_string(TEMPLATE).render(root=ROOT, urls=urls))