~ubuntu-branches/ubuntu/quantal/lazygal/quantal

« back to all changes in this revision

Viewing changes to lazygal.py

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2011-03-21 15:55:53 UTC
  • mfrom: (1.1.6 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110321155553-2qmag1i39n54hjv3
Tags: 0.6-2
* Update home page.
* Suggest gstreamer for video support.
* Require python 2.6 or newer (Closes: #619032).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
#
3
3
# Lazygal, a lazy satic web gallery generator.
4
 
# Copyright (C) 2007-2010 Alexandre Rossi <alexandre.rossi@gmail.com>
 
4
# Copyright (C) 2007-2011 Alexandre Rossi <alexandre.rossi@gmail.com>
5
5
#
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
38
38
    'dir-flattening-depth': 'No',
39
39
    'original': 'No',
40
40
    'orig-base': 'No',
 
41
    'orig-symlink': 'No',
41
42
    'image-size': 'small=800x600,medium=1024x768',
42
43
    'thumbnail-size': '150x113',
43
44
    'make-dir-zip': 'No',
143
144
                  dest="orig_base",
144
145
                  default=config.get('lazygal', 'orig-base'),
145
146
                  help=_("Do not copy original photos in output directory, instead link them using submitted relative path as base."))
 
147
parser.add_option("", "--orig-symlink",
 
148
                  action="store_true",
 
149
                  dest="orig_symlink",
 
150
                  default=config.get('lazygal', 'orig-symlink'),
 
151
                  help=_("Do not copy original photos in output directory, instead create symlinks to their original locations."))
146
152
parser.add_option("", "--puburl",
147
153
                  action="store", type="string",
148
154
                  dest="pub_url",
194
200
    print _("Directory %s does not exist.") % source_dir
195
201
    sys.exit(1)
196
202
 
 
203
if options.orig_symlink:
 
204
    try:
 
205
        _ = os.symlink
 
206
    except AttributeError:
 
207
        print _("Option --orig-symlink is not available on this platform.")
 
208
        sys.exit(1)
 
209
 
197
210
# Load a config file in the source_dir root
198
211
sourcedir_configfile = os.path.join(source_dir, SOURCEDIR_CONFIGFILE)
199
212
if os.path.isfile(sourcedir_configfile):
221
234
size_strings = []
222
235
size_defs = options.image_size.split(',')
223
236
for single_def in size_defs:
224
 
    name, string_size = single_def.split('=')
 
237
    try:
 
238
        name, string_size = single_def.split('=')
 
239
        if name == '': raise ValueError
 
240
    except ValueError:
 
241
        print _("Sizes is a comma-separated list of size names and specs:\n\t e.g. \"small=640x480,medium=1024x768\".")
 
242
        sys.exit(1)
225
243
    if name == THUMB_SIZE_NAME:
226
244
        print _("Size name '%s' is reserved for internal processing.")\
227
245
                % THUMB_SIZE_NAME
278
296
orig_base = None
279
297
if options.original and options.orig_base != 'No':
280
298
    orig_base = options.orig_base
281
 
album.set_original(options.original, orig_base)
 
299
album.set_original(options.original, orig_base, options.orig_symlink)
282
300
 
283
301
album.set_webalbumpic(bg=options.webalbumpic_bg)
284
302
 
291
309
    album.set_logging(log_level)
292
310
 
293
311
if options.metadata:
294
 
    album.generate_default_medatada()
 
312
    album.generate_default_metadata()
295
313
else:
296
314
    album.generate(options.dest_dir, options.pub_url,
297
315
                   options.check_all_dirs, options.clean_dest)