new cli option to force the reprocessing of existing images and thumbnails
This commit is contained in:
4
sigal.py
4
sigal.py
@@ -46,6 +46,8 @@ def main():
|
||||
|
||||
parser.add_option("-c", "--copyright", dest="copyright",
|
||||
help="copyright message added to the images")
|
||||
parser.add_option("-f", "--force", dest="force",
|
||||
help="force the reprocessing of existing images and thumbnails")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
@@ -68,7 +70,7 @@ def main():
|
||||
|
||||
# create gallery
|
||||
gallery = Gallery(params)
|
||||
gallery.build(input_dir, output_dir)
|
||||
gallery.build(input_dir, output_dir, force=options.force)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -61,11 +61,12 @@ class Gallery:
|
||||
if len(imglist) != 0:
|
||||
yield dirpath, dirnames, imglist
|
||||
|
||||
def build(self, input_dir, output_dir):
|
||||
def build(self, input_dir, output_dir, force=False):
|
||||
"create image gallery"
|
||||
|
||||
self.input_dir = os.path.abspath(input_dir)
|
||||
self.output_dir = os.path.abspath(output_dir)
|
||||
self.force = force
|
||||
|
||||
if not os.path.isdir(self.output_dir):
|
||||
print "Create output directory %s" % self.output_dir
|
||||
@@ -106,7 +107,8 @@ class Gallery:
|
||||
im_name = os.path.join(img_dir, filename)
|
||||
thumb_name = os.path.join(thumb_dir, self.thumb_prefix+filename)
|
||||
|
||||
if os.path.isfile(im_name) and os.path.isfile(thumb_name):
|
||||
if os.path.isfile(im_name) and os.path.isfile(thumb_name) and \
|
||||
not self.force:
|
||||
print "%s exists - skipping" % filename
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user