split --force-update into --force-thumb/--force-html options, implement for main
--- a/degal/commands/main.py Thu Jun 11 23:57:20 2009 +0300
+++ b/degal/commands/main.py Thu Jun 11 23:57:53 2009 +0300
@@ -6,6 +6,8 @@
Render the thumbnails and .html for one image
"""
+ ctx.log_debug("%s", image.html)
+
# render output
tpl = templates.master(ctx.gallery, image.title, image.html,
templates.image_page(image)
@@ -21,7 +23,7 @@
image.update()
-def render_folder_images (ctx, images) :
+def render_folder_images (ctx, images, for_update=True) :
"""
Render the given series of images
"""
@@ -31,12 +33,18 @@
# log image path
ctx.log_info("%s", image)
- # render output thumbs
- render_image_thumbs(image)
+ # only test if not already filtered for update
+ if for_update or image.stale() :
+ # render output thumbs
+ render_image_thumbs(image)
# render HTML
render_image_html(ctx, image)
+ # release large objects that are not needed anymore
+ # XXX: verify that this works
+ del image.pil_image
+
def render_folder_page (ctx, folder) :
"""
Render the .html output for one folder
@@ -46,6 +54,8 @@
for page in xrange(folder.page_count) :
# output .html page
html_file = folder.html_file(page)
+
+ ctx.log_debug("%s", html_file)
# render template
tpl = templates.master(ctx.gallery, folder.title, html_file,
@@ -59,19 +69,29 @@
"""
Render the HTML/images for this folder if needed, and recrurse into subfolders.
"""
+
+ if ctx.config.force_html or ctx.config.force_thumb :
+ # index all
+ for_update = False
- # index images that require updating
+ else :
+ # only new images
+ for_update = True
+
+ # full count of images
image_count = len(folder.images)
- new_images = list(folder.index_images(for_update=(not ctx.config.force_update)))
-
- if new_images or ctx.config.force_update:
+
+ # index selected images
+ new_images = list(folder.index_images(for_update=for_update))
+
+ if new_images or ctx.config.force_html :
# update folder index
render_folder_page(ctx, folder)
ctx.log_info("%s - render %d/%d images", folder, len(new_images), image_count)
# update images
- render_folder_images(ctx, new_images)
+ render_folder_images(ctx, new_images, for_update)
else :
ctx.log_info("%s - up to date", folder)
--- a/degal/config.py Thu Jun 11 23:57:20 2009 +0300
+++ b/degal/config.py Thu Jun 11 23:57:53 2009 +0300
@@ -17,7 +17,8 @@
gallery_path = "."
# force-update items
- force_update = False
+ force_thumb = False
+ force_html = False
# minimum logging level
log_level = logging.INFO
--- a/degal/main.py Thu Jun 11 23:57:20 2009 +0300
+++ b/degal/main.py Thu Jun 11 23:57:53 2009 +0300
@@ -22,7 +22,19 @@
help="Do not attempt to modify the gallery")
parser.add_option('-F', "--force-update", dest='force_update', action="store_true", default=False,
- help="Force updates, even for fresh items")
+ help="--force-thumb + --force-html")
+
+ parser.add_option("--force-thumb", dest='force_thumb', action="store_true", default=False,
+ help="Force-update all thumbnails")
+
+ parser.add_option("--force-html", dest='force_html', action="store_true", default=False,
+ help="Force-update all .html files")
+
+ parser.add_option('-d', "--debug", dest='debug', action="store_true", default=False,
+ help="Show debug output")
+
+ parser.add_option('-q', "--quiet", dest='quiet', action="store_true", default=False,
+ help="Reduced output")
return parser
@@ -42,7 +54,20 @@
config.read_only = True
if options.force_update :
- config.force_update = True
+ config.force_html = True
+ config.force_thumb = True
+
+ if options.force_thumb :
+ config.force_thumb = True
+
+ if options.force_html :
+ config.force_html = True
+
+ if options.debug :
+ config.log_level = config_module.logging.DEBUG
+
+ if options.quiet :
+ config.log_level = config_module.logging.WARN
# XXX: load config file(s)