config.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Radicale Server - Calendar Server
  4. # Copyright © 2008-2010 Guillaume Ayoub
  5. # Copyright © 2008 Nicolas Kandel
  6. # Copyright © 2008 Pascal Halter
  7. #
  8. # This library is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  20. """
  21. Radicale configuration module.
  22. Give a configparser-like interface to read and write configuration.
  23. """
  24. # TODO: Use abstract filenames for other platforms
  25. import os
  26. try:
  27. from configparser import RawConfigParser as ConfigParser
  28. except ImportError:
  29. from ConfigParser import RawConfigParser as ConfigParser
  30. _config = ConfigParser()
  31. get = _config.get
  32. set = _config.set
  33. getboolean = _config.getboolean
  34. getint = _config.getint
  35. getfloat = _config.getfloat
  36. options = _config.options
  37. items = _config.items
  38. _initial = {
  39. "server": {
  40. "host": "",
  41. "port": "5232",
  42. "daemon": "False",
  43. "ssl": "False",
  44. "certificate": "/etc/apache2/ssl/server.crt",
  45. "key": "/etc/apache2/ssl/server.key",
  46. #"log": "/var/www/radicale/server.log",
  47. },
  48. "encoding": {
  49. "request": "utf-8",
  50. "stock": "utf-8",
  51. },
  52. "namespace": {
  53. "C": "urn:ietf:params:xml:ns:caldav",
  54. "D": "DAV:",
  55. "CS": "http://calendarserver.org/ns/",
  56. },
  57. "acl": {
  58. "type": "fake",
  59. "filename": "/etc/radicale/users",
  60. "encryption": "crypt",
  61. },
  62. "support": {
  63. "type": "plain",
  64. "folder": os.path.expanduser("~/.config/radicale"),
  65. "calendar": "radicale/calendar",
  66. },
  67. }
  68. for section, values in _initial.items():
  69. _config.add_section(section)
  70. for key, value in values.items():
  71. _config.set(section, key, value)
  72. _config.read("/etc/radicale/config")
  73. _config.read(os.path.expanduser("~/.config/radicale/config"))