Use single setting name

This commit is contained in:
Matthias Vogelgesang
2013-07-30 09:00:05 +02:00
parent 80b5ae5505
commit 9e1ff67e8f
3 changed files with 15 additions and 16 deletions

View File

@@ -227,11 +227,8 @@ class Gallery(object):
try:
# loop on images
zip_files = self.settings['zip_gallery']
if zip_files:
archive_name = join(outpath, self.settings['zip_name'])
archive = zipfile.ZipFile(archive_name, 'w')
if self.settings['zip_gallery']:
self._zip_files(outpath, media_files)
for f in media_iterator:
filename = os.path.split(f)[1]
@@ -243,9 +240,6 @@ class Gallery(object):
else:
raise FileExtensionError
if zip_files:
archive.write(f, filename)
if os.path.isfile(outname) and not self.force:
self.logger.info("%s exists - skipping", filename)
else:
@@ -257,12 +251,19 @@ class Gallery(object):
else:
raise FileExtensionError
if zip_files:
archive.close()
except KeyboardInterrupt:
sys.exit('Interrupted')
def _zip_files(self, outpath, filepaths):
archive_name = join(outpath, str(self.settings['zip_gallery']))
archive = zipfile.ZipFile(archive_name, 'w')
for p in filepaths:
filename = os.path.split(p)[1]
archive.write(p, filename)
archive.close()
def process_image(filepath, outpath, settings):
"""Process one image: resize, create thumbnail."""

View File

@@ -81,6 +81,6 @@ thumb_size = (280, 210)
# Google Analytics tracking code (UA-xxxx-x)
# google_analytics = ''
# Zip gallery
# zip_gallery = False
# zip_name = 'archive.zip'
# Set zip_gallery to either False or a file name. The final archive will
# contain all original files.
# zip_gallery = False # False or 'archive.zip'

View File

@@ -144,8 +144,6 @@ class Writer(object):
if relpath != '.':
ctx['breadcumb'] = self.get_breadcumb(paths, relpath)
ctx['settings']['zip_gallery'] = not not paths[relpath]['medias']
for i in paths[relpath]['medias']:
media_ctx = {}
base, ext = os.path.splitext(i)