diff --git a/runtests.py b/runtests.py index 69e2980..8b0351e 100755 --- a/runtests.py +++ b/runtests.py @@ -25,15 +25,15 @@ additionnal information for debugging purpose. import os import sys -import sigal from sigal.image import Gallery +from sigal.params import read_params if __name__ == '__main__': # read params from config file config_file = os.path.join(sys.path[0], 'sigal.conf') print ":: Reading parameters ..." - params = sigal.read_params(config_file) + params = read_params(config_file) print "\n".join(["%s=%s" % (k, v) for k, v in params.items()]) print "\n" diff --git a/sigal.py b/sigal.py index ce5fbe2..01a7076 100755 --- a/sigal.py +++ b/sigal.py @@ -31,29 +31,10 @@ __license__ = "GPL" import os import sys -from configobj import ConfigObj from optparse import OptionParser from sigal.ftp import FtpUpload from sigal.image import Gallery - - -def read_params(config_file): - "Read params from a config file" - - params = ConfigObj(config_file,file_error=True) - - # convert types - params["im_width"] = int(params["im_width"]) - params["im_height"] = int(params["im_height"]) - params["thumb_width"] = int(params["thumb_width"]) - params["thumb_height"] = int(params["thumb_height"]) - params["bigimg"] = int(params["bigimg"]) - params["squarethumb"] = int(params["squarethumb"]) - params["jpgquality"] = int(params["jpgquality"]) - params["exif"] = int(params["exif"]) - params["copyright"] = int(params["copyright"]) - return params - +from sigal.params import read_params def main(): "main program" diff --git a/sigal/params.py b/sigal/params.py new file mode 100644 index 0000000..fb92ff0 --- /dev/null +++ b/sigal/params.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python2 +# -*- coding:utf-8 -*- + +# sigal - Piwigo gallery generator +# Copyright (C) 2009-2011 Simon - 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/ + +"""Parameters utils""" + +from configobj import ConfigObj + +def read_params(config_file): + "Read params from a config file" + + params = ConfigObj(config_file,file_error=True) + + # convert types + params["im_width"] = int(params["im_width"]) + params["im_height"] = int(params["im_height"]) + params["thumb_width"] = int(params["thumb_width"]) + params["thumb_height"] = int(params["thumb_height"]) + params["bigimg"] = int(params["bigimg"]) + params["squarethumb"] = int(params["squarethumb"]) + params["jpgquality"] = int(params["jpgquality"]) + params["exif"] = int(params["exif"]) + params["copyright"] = int(params["copyright"]) + return params