1.1 --- a/tools/make_freebusy.py Sat Apr 04 23:25:53 2015 +0200
1.2 +++ b/tools/make_freebusy.py Sun Apr 05 00:49:41 2015 +0200
1.3 @@ -2,6 +2,7 @@
1.4
1.5 from imiptools.data import get_window_end, Object
1.6 from imiptools.dates import format_datetime, get_default_timezone
1.7 +from imiptools.period import FreeBusyPeriod
1.8 from imiptools.profile import Preferences
1.9 from imip_store import FileStore, FilePublisher
1.10 import sys
1.11 @@ -12,10 +13,10 @@
1.12
1.13 recurrenceid = format_datetime(obj.get_utc_datetime("RECURRENCE-ID")) or ""
1.14
1.15 - for start, end in obj.get_periods_for_freebusy(tzid, window_end):
1.16 - if recurrenceid or start not in recurrenceids:
1.17 - fb.append((
1.18 - start, end,
1.19 + for p in obj.get_periods_for_freebusy(tzid, window_end):
1.20 + if recurrenceid or p.start not in recurrenceids:
1.21 + fb.append(FreeBusyPeriod(
1.22 + p.start, p.end,
1.23 obj.get_value("UID"),
1.24 only_organiser and "ORG" or obj.get_value("TRANSP") or "OPAQUE",
1.25 recurrenceid,
1.26 @@ -28,9 +29,10 @@
1.27 try:
1.28 user = sys.argv[1]
1.29 args = sys.argv[2:]
1.30 - participant = args and args[0] not in ("-n", "-s") and args[0] or user
1.31 + participant = args and args[0] not in ("-n", "-s", "-v") and args[0] or user
1.32 store_and_publish = "-s" in args
1.33 include_needs_action = "-n" in args
1.34 + verbose = "-v" in args
1.35 except IndexError:
1.36 print >>sys.stderr, """\
1.37 Need a user and an optional participant (if different from the user),
1.38 @@ -70,7 +72,8 @@
1.39
1.40 objs = []
1.41 for uid, recurrenceid in all_events:
1.42 - print >>sys.stderr, uid, recurrenceid
1.43 + if verbose:
1.44 + print >>sys.stderr, uid, recurrenceid
1.45 event = store.get_event(user, uid, recurrenceid)
1.46 if event:
1.47 objs.append(Object(event))
1.48 @@ -116,6 +119,6 @@
1.49 store.set_freebusy_for_other(user, fb, participant)
1.50 else:
1.51 for item in fb:
1.52 - print "\t".join(item)
1.53 + print "\t".join(item.as_tuple())
1.54
1.55 # vim: tabstop=4 expandtab shiftwidth=4