From bfc5d0ca2e81eede9dec00a2d5f85c16b401f717 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 14 May 2012 00:44:07 +0200 Subject: [PATCH] simplify params to keep only one config_file --- sigal/params.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sigal/params.py b/sigal/params.py index e89c220..8a37984 100644 --- a/sigal/params.py +++ b/sigal/params.py @@ -17,14 +17,12 @@ # 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""" - import os import ConfigParser -CONFIGFILE = '~/.config/sigal/sigal.conf' -SOURCEDIR_CONFIGFILE = 'sigal.conf' -CONFIGDEFAULTS = { +CONFIG_FILE = 'sigal.conf' + +_DEFAULT_CONFIG = { 'img_size': '640x480', 'thumb_prefix': '', 'thumb_size': '150x112', @@ -38,16 +36,16 @@ CONFIGDEFAULTS = { 'fileExtList': ".jpg,.jpeg,.JPG,.JPEG,.png" } + def read_params(source_dir): - "Read params from a config file" + "Read params from a config file in the source_dir root" # Read configuration file - config = ConfigParser.ConfigParser(defaults = CONFIGDEFAULTS) - config.read(os.path.expanduser(CONFIGFILE)) + config = ConfigParser.ConfigParser(defaults=_DEFAULT_CONFIG) # Load a config file in the source_dir root - sourcedir_configfile = os.path.join(source_dir, SOURCEDIR_CONFIGFILE) - if os.path.isfile(sourcedir_configfile): - config.read(sourcedir_configfile) + config = os.path.join(source_dir, CONFIG_FILE) + if os.path.isfile(config): + config.read(config) return config