2010-01-15 00:15:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-12-30 16:25:42 +00:00
|
|
|
#
|
|
|
|
# This file is part of Radicale Server - Calendar Server
|
2011-01-09 17:46:22 +01:00
|
|
|
# Copyright © 2008-2011 Guillaume Ayoub
|
2009-07-27 15:04:54 +00:00
|
|
|
# Copyright © 2008 Nicolas Kandel
|
|
|
|
# Copyright © 2008 Pascal Halter
|
2008-12-30 16:25:42 +00: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 15:04:54 +00: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 15:04:54 +00:00
|
|
|
"""
|
|
|
|
|
2010-01-18 10:48:06 +01:00
|
|
|
import os
|
2010-02-10 18:57:21 +01:00
|
|
|
import sys
|
2010-02-10 23:52:50 +01:00
|
|
|
# Manage Python2/3 different modules
|
2010-06-05 01:18:59 +02:00
|
|
|
# pylint: disable=F0401
|
2010-01-15 16:04:03 +01:00
|
|
|
try:
|
|
|
|
from configparser import RawConfigParser as ConfigParser
|
|
|
|
except ImportError:
|
|
|
|
from ConfigParser import RawConfigParser as ConfigParser
|
2010-06-05 01:18:59 +02:00
|
|
|
# pylint: enable=F0401
|
2008-12-30 16:25:42 +00:00
|
|
|
|
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Default configuration
|
|
|
|
INITIAL_CONFIG = {
|
2008-12-30 16:25:42 +00:00
|
|
|
"server": {
|
2011-04-02 21:49:48 +02:00
|
|
|
"hosts": "0.0.0.0: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",
|
2010-02-10 23:52:50 +01:00
|
|
|
"key": "/etc/apache2/ssl/server.key"},
|
2008-12-30 16:25:42 +00:00
|
|
|
"encoding": {
|
|
|
|
"request": "utf-8",
|
2010-02-10 23:52:50 +01:00
|
|
|
"stock": "utf-8"},
|
2008-12-30 16:25:42 +00:00
|
|
|
"acl": {
|
2011-04-10 18:17:06 +02:00
|
|
|
"type": "None",
|
2010-07-03 16:27:48 +02:00
|
|
|
"personal": "False",
|
2010-01-21 18:52:53 +01:00
|
|
|
"filename": "/etc/radicale/users",
|
2010-02-10 23:52:50 +01:00
|
|
|
"encryption": "crypt"},
|
|
|
|
"storage": {
|
2010-12-02 17:58:56 +01:00
|
|
|
"folder": os.path.expanduser("~/.config/radicale/calendars")},
|
2011-02-16 13:53:27 +01:00
|
|
|
"logging": {
|
2011-04-10 18:55:49 +02:00
|
|
|
<<<<<<< HEAD
|
2011-04-07 16:27:47 +02:00
|
|
|
"type": "stdout",
|
2011-02-22 18:13:35 +01:00
|
|
|
"logfile": os.path.expanduser("~/.config/radicale/radicale.log"),
|
2011-02-16 14:17:28 +01:00
|
|
|
"facility": 10},
|
2010-12-02 17:58:56 +01:00
|
|
|
"authLdap": {
|
|
|
|
"LDAPServer": "127.0.0.1",
|
|
|
|
"LDAPPrepend": "uid=",
|
2011-02-16 14:50:42 +01:00
|
|
|
"LDAPAppend": "ou=users,dc=example,dc=com"}}
|
2011-04-10 18:55:49 +02:00
|
|
|
=======
|
2011-04-10 18:17:06 +02:00
|
|
|
"config": "/etc/radicale/logging",
|
|
|
|
"debug": "False"}}
|
2011-04-10 18:55:49 +02:00
|
|
|
>>>>>>> d9ea784e31687b03f1451bc5b543122f05c5deb1
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Create a ConfigParser and configure it
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER = ConfigParser()
|
2010-02-10 18:57:21 +01:00
|
|
|
|
|
|
|
for section, values in INITIAL_CONFIG.items():
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.add_section(section)
|
2010-01-15 16:04:03 +01:00
|
|
|
for key, value in values.items():
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.set(section, key, value)
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.read("/etc/radicale/config")
|
2011-04-07 16:27:47 +02:00
|
|
|
_CONFIG_PARSER.read(os.path.expdanuser("~/.config/radicale/config"))
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Wrap config module into ConfigParser instance
|
2010-02-10 23:52:50 +01:00
|
|
|
sys.modules[__name__] = _CONFIG_PARSER
|