1.1 --- a/imip_store.py Tue Dec 09 00:24:14 2014 +0100
1.2 +++ b/imip_store.py Tue Dec 09 00:25:27 2014 +0100
1.3 @@ -2,8 +2,8 @@
1.4
1.5 from datetime import datetime
1.6 from imiptools.config import STORE_DIR, PUBLISH_DIR
1.7 -from os.path import abspath, commonprefix, exists, join, split
1.8 -from os import chmod, makedirs
1.9 +from os.path import abspath, commonprefix, exists, isfile, join, split
1.10 +from os import chmod, listdir, makedirs
1.11 from vCalendar import iterwrite
1.12
1.13 def check_dir(base, dir):
1.14 @@ -69,6 +69,16 @@
1.15
1.16 "A file store of tabular free/busy data and objects."
1.17
1.18 + def get_events(self, user):
1.19 +
1.20 + "Return a list of event identifiers."
1.21 +
1.22 + filename = self.get_object_in_store(user)
1.23 + if not filename or not exists(filename):
1.24 + return None
1.25 +
1.26 + return [name for name in listdir(filename) if isfile(join(filename, name))]
1.27 +
1.28 def get_event(self, user, uid):
1.29
1.30 "Get the event for the given 'user' with the given 'uid'."
1.31 @@ -77,7 +87,7 @@
1.32 if not filename or not exists(filename):
1.33 return None
1.34
1.35 - return exists(filename) and open(filename) or None
1.36 + return open(filename) or None
1.37
1.38 def set_event(self, user, uid, node):
1.39
1.40 @@ -152,7 +162,7 @@
1.41 f = open(filename, "w")
1.42 try:
1.43 for item in freebusy:
1.44 - f.write("\t".join(item) + "\n")
1.45 + f.write("\t".join([(value or "OPAQUE") for value in item]) + "\n")
1.46 finally:
1.47 f.close()
1.48 fix_permissions(filename)
1.49 @@ -254,7 +264,7 @@
1.50 rwrite(("DTSTAMP", {}, datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")))
1.51
1.52 for start, end, uid, transp in freebusy:
1.53 - if transp == "OPAQUE":
1.54 + if not transp or transp == "OPAQUE":
1.55 rwrite(("FREEBUSY", {"FBTYPE" : "BUSY"}, "/".join([start, end])))
1.56
1.57 f = open(filename, "w")