simplify params to keep only one config_file
This commit is contained in:
@@ -17,14 +17,12 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; If not, see http://www.gnu.org/licenses/
|
# along with this program; If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
"""Parameters utils"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
CONFIGFILE = '~/.config/sigal/sigal.conf'
|
CONFIG_FILE = 'sigal.conf'
|
||||||
SOURCEDIR_CONFIGFILE = 'sigal.conf'
|
|
||||||
CONFIGDEFAULTS = {
|
_DEFAULT_CONFIG = {
|
||||||
'img_size': '640x480',
|
'img_size': '640x480',
|
||||||
'thumb_prefix': '',
|
'thumb_prefix': '',
|
||||||
'thumb_size': '150x112',
|
'thumb_size': '150x112',
|
||||||
@@ -38,16 +36,16 @@ CONFIGDEFAULTS = {
|
|||||||
'fileExtList': ".jpg,.jpeg,.JPG,.JPEG,.png"
|
'fileExtList': ".jpg,.jpeg,.JPG,.JPEG,.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def read_params(source_dir):
|
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
|
# Read configuration file
|
||||||
config = ConfigParser.ConfigParser(defaults = CONFIGDEFAULTS)
|
config = ConfigParser.ConfigParser(defaults=_DEFAULT_CONFIG)
|
||||||
config.read(os.path.expanduser(CONFIGFILE))
|
|
||||||
|
|
||||||
# Load a config file in the source_dir root
|
# Load a config file in the source_dir root
|
||||||
sourcedir_configfile = os.path.join(source_dir, SOURCEDIR_CONFIGFILE)
|
config = os.path.join(source_dir, CONFIG_FILE)
|
||||||
if os.path.isfile(sourcedir_configfile):
|
if os.path.isfile(config):
|
||||||
config.read(sourcedir_configfile)
|
config.read(config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|||||||
Reference in New Issue
Block a user