config.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. try:
  26. from configparser import RawConfigParser as ConfigParser
  27. except ImportError:
  28. from ConfigParser import RawConfigParser as ConfigParser
  29. _config = ConfigParser()
  30. get = _config.get
  31. set = _config.set
  32. getboolean = _config.getboolean
  33. getint = _config.getint
  34. getfloat = _config.getfloat
  35. options = _config.options
  36. items = _config.items
  37. _initial = {
  38. "server": {
  39. "protocol": "http",
  40. "name": "",
  41. "port": "5232",
  42. #"certificate": "/etc/apache2/ssl/server.crt",
  43. #"privatekey": "/etc/apache2/ssl/server.key",
  44. #"log": "/var/www/radicale/server.log",
  45. },
  46. "encoding": {
  47. "request": "utf-8",
  48. "stock": "utf-8",
  49. },
  50. "namespace": {
  51. "C": "urn:ietf:params:xml:ns:caldav",
  52. "D": "DAV:",
  53. "CS": "http://calendarserver.org/ns/",
  54. },
  55. "acl": {
  56. "type": "fake",
  57. #"filename": "/etc/radicale/users",
  58. },
  59. "support": {
  60. "type": "plain",
  61. "folder": "~/.config/radicale",
  62. "calendar": "radicale/calendar",
  63. },
  64. }
  65. for section, values in _initial.items():
  66. _config.add_section(section)
  67. for key, value in values.items():
  68. _config.set(section, key, value)
  69. _config.read("/etc/radicale/config")