|
|
|
|
|
|
|
|
#!/usr/bin/env python3 |
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
|
import os |
|
|
import os |
|
|
|
|
|
import shutil |
|
|
|
|
|
|
|
|
from jinja2 import Environment, PackageLoader, select_autoescape |
|
|
from jinja2 import Environment, PackageLoader, select_autoescape |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_output_dir(): |
|
|
def generate_output_dir(): |
|
|
output_path = os.path.join(os.curdir, OUTPUT_DIR_NAME) |
|
|
output_path = os.path.join(os.curdir, OUTPUT_DIR_NAME) |
|
|
|
|
|
shutil.rmtree(output_path) |
|
|
if not os.path.isdir(output_path): |
|
|
if not os.path.isdir(output_path): |
|
|
os.mkdir(output_path) |
|
|
os.mkdir(output_path) |
|
|
return output_path |
|
|
return output_path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_index(galleries, output_path): |
|
|
|
|
|
|
|
|
def generate_style(output_path): |
|
|
|
|
|
style_path = os.path.join(os.curdir, THEME, "style") |
|
|
|
|
|
style_output_path = os.path.join(output_path, "style") |
|
|
|
|
|
shutil.copytree(style_path, style_output_path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_index(output_path, galleries): |
|
|
index_path = os.path.join(output_path, "index.html") |
|
|
index_path = os.path.join(output_path, "index.html") |
|
|
|
|
|
|
|
|
theme_path = os.path.join(os.curdir, THEME) |
|
|
theme_path = os.path.join(os.curdir, THEME) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(galleries) > 0: |
|
|
if len(galleries) > 0: |
|
|
output_path = generate_output_dir() |
|
|
output_path = generate_output_dir() |
|
|
generate_index(galleries, output_path) |
|
|
|
|
|
|
|
|
generate_style(output_path) |
|
|
|
|
|
generate_index(output_path, galleries) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |