import re
import subprocess
+import ConfigParser
+
from . import config, paths
+METADATA_FILENAME = ".calypso-collection"
+
#
# Recursive search for 'name' within 'vobject'
#
"""Internal collection class."""
def get_description(self):
+ try:
+ return str(self.metadata.get('collection', 'description'))
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
+ pass
+
try:
f = codecs.open(os.path.join(self.path, ".git/description"), encoding='utf-8')
except IOError:
self.remove_file(path)
self.insert_file(path)
+ __metadatafile = property(lambda self: os.path.join(self.path, METADATA_FILENAME))
+
+ def scan_metadata(self, force):
+ try:
+ mtime = os.path.getmtime(self.__metadatafile)
+ except OSError:
+ mtime = 0
+ force = True
+
+ if not force and mtime == self.mtime and self.metadata is not None:
+ return
+
+ parser = ConfigParser.RawConfigParser()
+ parser.read(self.__metadatafile)
+ self.metadata = parser
+
def scan_dir(self, force):
try:
mtime = os.path.getmtime(self.path)
mtime = 0
force = True
+ self.scan_metadata(force)
+
if not force and mtime == self.mtime:
return
self.log.debug("Scan %s", self.path)
filenames = glob.glob(self.pattern)
newfiles = []
for filename in filenames:
+ if filename == METADATA_FILENAME:
+ continue
for file in self.files:
if filename == file.path:
newfiles.append(file)
self.mtime = 0
self._ctag = ''
self.etag = hashlib.sha1(self.path).hexdigest()
+ self.metadata = None
+ self.metadata_mtime = None
self.scan_dir(False)
self.tag = "Collection"
--- /dev/null
+# Per-collection config file for Calypso
+#
+# Name it .calypso-collection and place it into a collection to tune its
+# behavior; a typical location for it would be
+# ~/.config/calypso/calendars/private/test/.calypso-collection
+
+[collection]
+# Short name. Defaults to the collection's path.
+displayname = My Calendar
+# Description used for the addressbook-description and calendar-description
+# WebDAV properties. Defaults to the collection's path.
+description = Collection of all my personal dates.
+
+# vim:ft=cfg