<commit_before>#!/usr/bin/env python2
# -*- coding:utf-8 -*-

# sigal - simple static gallery generator
# Copyright (C) 2009-2012 - <NAME>. (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 3 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"""

import os
import ConfigParser

CONFIGFILE = '~/.config/sigal/sigal.conf'
SOURCEDIR_CONFIGFILE = 'sigal.conf'
CONFIGDEFAULTS = {
    'img_size': '640x480',
    'thumb_prefix': '',
    'thumb_size': '150x112',
    'thumb_dir': "thumbnail",
    'square_thumb': 0,
    'big_img': 0,
    'bigimg_dir': "big",
    'jpg_quality': 90,
    'exif': 1,
    'copyright': '',
    'fileExtList': ".jpg,.jpeg,.JPG,.JPEG,.png"
    }

def read_params(source_dir):
    "Read params from a config file"

    # Read configuration file
    config = ConfigParser.ConfigParser(defaults = CONFIGDEFAULTS)
    config.read(os.path.expanduser(CONFIGFILE))

    # 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)

    return config<commit_msg>simplify params to keep only one config_file<commit_after>#!/usr/bin/env python2
# -*- coding:utf-8 -*-

# sigal - simple static gallery generator
# Copyright (C) 2009-2012 - <NAME>. (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 3 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/

import os
import ConfigParser

CONFIG_FILE = 'sigal.conf'

_DEFAULT_CONFIG = {
    'img_size': '640x480',
    'thumb_prefix': '',
    'thumb_size': '150x112',
    'thumb_dir': "thumbnail",
    'square_thumb': 0,
    'big_img': 0,
    'bigimg_dir': "big",
    'jpg_quality': 90,
    'exif': 1,
    'copyright': '',
    'fileExtList': ".jpg,.jpeg,.JPG,.JPEG,.png"
    }


def read_params(source_dir):
    "Read params from a config file in the source_dir root"

    # Read configuration file
    config = ConfigParser.ConfigParser(defaults=_DEFAULT_CONFIG)

    # Load a config file in the source_dir root
    config = os.path.join(source_dir, CONFIG_FILE)
    if os.path.isfile(config):
        config.read(config)

    return config
{'fraction_non_alphanumeric': 0.10679012345679012, 'fraction_numerical': 0.01728395061728395, 'mean_word_length': 3.7521994134897363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4353350', 'n_tokens_mistral': 1032, 'n_tokens_neox': 985, 'n_words': 351}