2010-01-15 00:15:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-12-30 17:25:42 +01:00
|
|
|
#
|
|
|
|
# This file is part of Radicale Server - Calendar Server
|
2010-01-15 00:15:41 +01:00
|
|
|
# Copyright © 2008-2010 Guillaume Ayoub
|
2009-07-27 17:04:54 +02:00
|
|
|
# Copyright © 2008 Nicolas Kandel
|
|
|
|
# Copyright © 2008 Pascal Halter
|
2008-12-30 17:25:42 +01:00
|
|
|
#
|
|
|
|
# This library 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 library 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 Radicale. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-07-27 17:04:54 +02:00
|
|
|
"""
|
|
|
|
Radicale configuration module.
|
|
|
|
|
|
|
|
Give a configparser-like interface to read and write configuration.
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2009-07-27 17:04:54 +02:00
|
|
|
"""
|
|
|
|
|
2010-01-16 13:33:50 +01:00
|
|
|
# TODO: Use abstract filenames for other platforms
|
|
|
|
|
2010-01-18 10:48:06 +01:00
|
|
|
import os
|
2010-02-10 18:57:21 +01:00
|
|
|
import sys
|
2010-01-15 16:04:03 +01:00
|
|
|
try:
|
|
|
|
from configparser import RawConfigParser as ConfigParser
|
|
|
|
except ImportError:
|
|
|
|
from ConfigParser import RawConfigParser as ConfigParser
|
2008-12-30 17:25:42 +01:00
|
|
|
|
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Default configuration
|
|
|
|
INITIAL_CONFIG = {
|
2008-12-30 17:25:42 +01:00
|
|
|
"server": {
|
2010-01-19 17:49:32 +01:00
|
|
|
"host": "",
|
2008-12-30 20:26:03 +01:00
|
|
|
"port": "5232",
|
2010-01-18 10:48:06 +01:00
|
|
|
"daemon": "False",
|
2010-01-19 17:49:32 +01:00
|
|
|
"ssl": "False",
|
|
|
|
"certificate": "/etc/apache2/ssl/server.crt",
|
|
|
|
"key": "/etc/apache2/ssl/server.key",
|
2008-12-30 17:25:42 +01:00
|
|
|
},
|
|
|
|
"encoding": {
|
|
|
|
"request": "utf-8",
|
|
|
|
"stock": "utf-8",
|
|
|
|
},
|
|
|
|
"acl": {
|
2008-12-30 20:26:03 +01:00
|
|
|
"type": "fake",
|
2010-01-21 18:52:53 +01:00
|
|
|
"filename": "/etc/radicale/users",
|
|
|
|
"encryption": "crypt",
|
2008-12-30 17:25:42 +01:00
|
|
|
},
|
|
|
|
"support": {
|
|
|
|
"type": "plain",
|
2010-01-18 10:48:06 +01:00
|
|
|
"folder": os.path.expanduser("~/.config/radicale"),
|
2010-02-10 18:57:21 +01:00
|
|
|
"calendar": "radicale/cal",
|
2008-12-30 17:25:42 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Create a ConfigParser and configure it
|
|
|
|
_CONFIG = ConfigParser()
|
|
|
|
|
|
|
|
for section, values in INITIAL_CONFIG.items():
|
|
|
|
_CONFIG.add_section(section)
|
2010-01-15 16:04:03 +01:00
|
|
|
for key, value in values.items():
|
2010-02-10 18:57:21 +01:00
|
|
|
_CONFIG.set(section, key, value)
|
|
|
|
|
|
|
|
_CONFIG.read("/etc/radicale/config")
|
|
|
|
_CONFIG.read(os.path.expanduser("~/.config/radicale/config"))
|
2008-12-30 17:25:42 +01:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Wrap config module into ConfigParser instance
|
|
|
|
sys.modules[__name__] = _CONFIG
|