import dominate from dominate.tags import meta, h3, table, tr, td, p, a, img, br import glob import re import os import click import shutil from collections import OrderedDict import numpy as np def atoi(text): return int(text) if text.isdigit() else text def natural_keys(text): ''' alist.sort(key=natural_keys) sorts in human order http://nedbatchelder.com/blog/200712/human_sorting.html (See Toothy's implementation in the comments) ''' return [atoi(c) for c in re.split('(\d+)', text)] def natural_sort(items): items.sort(key=natural_keys) IMG_EXTENSIONS = [ '.jpg', '.JPG', '.jpeg', '.JPEG', '.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP', '.tiff', '.webp' ] def is_image_file(filename): return any(filename.endswith(extension) for extension in IMG_EXTENSIONS) class HTML: def __init__(self, title, web_dir_prefix='web_'): """Initialize the HTML classes Parameters: web_dir (str) -- a directory that stores the webpage. HTML file will be created at /index.html; images will be saved at