# HG changeset patch # User Tero Marttila # Date 1244745980 -10800 # Node ID 676c1d201cfe59ac16dba4fb7c00fd914a2ea342 # Parent d3872a673fbef1d3ba08663f7323deaca78775d5 slightly reoriganize function structure in commands.main diff -r d3872a673fbe -r 676c1d201cfe degal/commands/main.py --- a/degal/commands/main.py Thu Jun 11 21:46:09 2009 +0300 +++ b/degal/commands/main.py Thu Jun 11 21:46:20 2009 +0300 @@ -1,14 +1,11 @@ from degal.command import command from degal import templates -def render_image (ctx, image) : +def render_image_html (ctx, image) : """ Render the thumbnails and .html for one image """ - # log image path - ctx.log_info("%s", image) - # render output tpl = templates.master(ctx.gallery, image.title, image.html, templates.image_page(image) @@ -17,6 +14,29 @@ # write output tpl.render_file(image.html) +def render_image_thumbs (image) : + """ + Render the thubmnails for the given image + """ + + image.update() + +def render_folder_images (ctx, images) : + """ + Render the given series of images + """ + + # render them in parallel as required + for image in images : + # log image path + ctx.log_info("%s", image) + + # render output thumbs + render_image_thumbs(image) + + # render HTML + render_image_html(ctx, image) + def render_folder_page (ctx, folder) : """ Render the .html output for one folder @@ -34,9 +54,12 @@ # write output tpl.render_file(html_file) - def render_folder (ctx, folder) : + """ + Render the HTML/images for this folder if needed, and recrurse into subfolders. + """ + # index images that require updating image_count = len(folder.images) new_images = list(folder.index_images(for_update=(not ctx.config.force_update))) @@ -48,12 +71,7 @@ ctx.log_info("%s - render %d/%d images", folder, len(new_images), image_count) # update images - for image in new_images : - # update thumbs - image.update() - - # render output - render_image(ctx, image) + render_folder_images(ctx, new_images) else : ctx.log_info("%s - up to date", folder)