From fdd4170f94d794ac19f869da1f5d0e7658382621 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 13 May 2012 23:28:19 +0200 Subject: [PATCH] use entry_points for the main script --- bin/sigal | 82 ----------------------------------------------- setup.py | 9 ++++-- sigal/__init__.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 84 deletions(-) delete mode 100755 bin/sigal mode change 100644 => 100755 sigal/__init__.py diff --git a/bin/sigal b/bin/sigal deleted file mode 100755 index 4369f9f..0000000 --- a/bin/sigal +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/env python2 -# -*- coding:utf-8 -*- - -# sigal - simple static gallery generator -# Copyright (C) 2009-2012 - Simon C. (saimon.org) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; If not, see http://www.gnu.org/licenses/ - -""" -sigal - simple static gallery generator -======================================= - -sigal is yet another python script to prepare a static gallery of images: - -* resize images, create thumbnails with some options (squared thumbs, ...). -* generate html pages. -""" - -__author__ = "Saimon (contact at saimon dot org)" -__version__ = "0.1" -__date__ = "20110513" -__copyright__ = "Copyright (C) 2009-2012 - saimon.org" -__license__ = "GPL" - -import os -import sys -import argparse -from sigal.image import Gallery -from sigal.params import read_params -from sigal.theme import Theme - -def main(): - "main program" - - version = "version %s, %s" % (__version__, __date__) - - parser = argparse.ArgumentParser(description='simple static gallery generator.') - parser.add_argument('input_dir', help='input directory') - parser.add_argument('output_dir', help='output directory') - parser.add_argument('--version', action='version', - version="%(prog)s " + version) - parser.add_argument('-c', '--copyright', - help="copyright message added to the images") - parser.add_argument("-f", "--force", action='store_true', - help="force the reprocessing of existing images and thumbnails") - - args = parser.parse_args() - - if not os.path.isdir(args.input_dir): - print "Directory %s does not exist." % args.input_dir - sys.exit(1) - - print ":: Reading parameters ..." - params = read_params(args.input_dir) - - if args.copyright: - params.set('sigal', 'copyright', args.copyright) - - # create gallery - gallery = Gallery(params) - gallery.build(args.input_dir, args.output_dir, force=args.force) - - r = Theme(params, args.output_dir) - r.render() - - return 0 - - -if __name__ == '__main__': - status = main() - sys.exit(status) diff --git a/setup.py b/setup.py index 7e5327a..aa54eae 100644 --- a/setup.py +++ b/setup.py @@ -4,10 +4,15 @@ from setuptools import setup import sys -requires = ['imaging', 'jinja2', 'docutils'] +requires = ['PIL', 'jinja2', 'docutils'] if sys.version_info < (2,7): requires.append('argparse') +entry_points = { + 'console_scripts': + ['sigal = sigal:main'] + } + setup( name = 'sigal', version = '0.1', @@ -19,6 +24,6 @@ setup( license = 'GPLv3', include_package_data = True, install_requires = requires, + entry_points = entry_points, packages = ['sigal'], - scripts = ['bin/sigal'], ) diff --git a/sigal/__init__.py b/sigal/__init__.py old mode 100644 new mode 100755 index e69de29..4369f9f --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -0,0 +1,82 @@ +#! /usr/bin/env python2 +# -*- coding:utf-8 -*- + +# sigal - simple static gallery generator +# Copyright (C) 2009-2012 - Simon C. (saimon.org) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; If not, see http://www.gnu.org/licenses/ + +""" +sigal - simple static gallery generator +======================================= + +sigal is yet another python script to prepare a static gallery of images: + +* resize images, create thumbnails with some options (squared thumbs, ...). +* generate html pages. +""" + +__author__ = "Saimon (contact at saimon dot org)" +__version__ = "0.1" +__date__ = "20110513" +__copyright__ = "Copyright (C) 2009-2012 - saimon.org" +__license__ = "GPL" + +import os +import sys +import argparse +from sigal.image import Gallery +from sigal.params import read_params +from sigal.theme import Theme + +def main(): + "main program" + + version = "version %s, %s" % (__version__, __date__) + + parser = argparse.ArgumentParser(description='simple static gallery generator.') + parser.add_argument('input_dir', help='input directory') + parser.add_argument('output_dir', help='output directory') + parser.add_argument('--version', action='version', + version="%(prog)s " + version) + parser.add_argument('-c', '--copyright', + help="copyright message added to the images") + parser.add_argument("-f", "--force", action='store_true', + help="force the reprocessing of existing images and thumbnails") + + args = parser.parse_args() + + if not os.path.isdir(args.input_dir): + print "Directory %s does not exist." % args.input_dir + sys.exit(1) + + print ":: Reading parameters ..." + params = read_params(args.input_dir) + + if args.copyright: + params.set('sigal', 'copyright', args.copyright) + + # create gallery + gallery = Gallery(params) + gallery.build(args.input_dir, args.output_dir, force=args.force) + + r = Theme(params, args.output_dir) + r.render() + + return 0 + + +if __name__ == '__main__': + status = main() + sys.exit(status)