# HG changeset patch # User Paul Boddie # Date 1428187781 -7200 # Node ID f44bef24d6155c45d13d36d8f6657a79e0e8ef78 # Parent e380eda892383c9fbf2bf9654c1bafc9f335ac55 Updated the free/busy tool to work with recent period abstraction changes. diff -r e380eda89238 -r f44bef24d615 tools/make_freebusy.py --- a/tools/make_freebusy.py Sat Apr 04 23:25:53 2015 +0200 +++ b/tools/make_freebusy.py Sun Apr 05 00:49:41 2015 +0200 @@ -2,6 +2,7 @@ from imiptools.data import get_window_end, Object from imiptools.dates import format_datetime, get_default_timezone +from imiptools.period import FreeBusyPeriod from imiptools.profile import Preferences from imip_store import FileStore, FilePublisher import sys @@ -12,10 +13,10 @@ recurrenceid = format_datetime(obj.get_utc_datetime("RECURRENCE-ID")) or "" - for start, end in obj.get_periods_for_freebusy(tzid, window_end): - if recurrenceid or start not in recurrenceids: - fb.append(( - start, end, + for p in obj.get_periods_for_freebusy(tzid, window_end): + if recurrenceid or p.start not in recurrenceids: + fb.append(FreeBusyPeriod( + p.start, p.end, obj.get_value("UID"), only_organiser and "ORG" or obj.get_value("TRANSP") or "OPAQUE", recurrenceid, @@ -28,9 +29,10 @@ try: user = sys.argv[1] args = sys.argv[2:] - participant = args and args[0] not in ("-n", "-s") and args[0] or user + participant = args and args[0] not in ("-n", "-s", "-v") and args[0] or user store_and_publish = "-s" in args include_needs_action = "-n" in args + verbose = "-v" in args except IndexError: print >>sys.stderr, """\ Need a user and an optional participant (if different from the user), @@ -70,7 +72,8 @@ objs = [] for uid, recurrenceid in all_events: - print >>sys.stderr, uid, recurrenceid + if verbose: + print >>sys.stderr, uid, recurrenceid event = store.get_event(user, uid, recurrenceid) if event: objs.append(Object(event)) @@ -116,6 +119,6 @@ store.set_freebusy_for_other(user, fb, participant) else: for item in fb: - print "\t".join(item) + print "\t".join(item.as_tuple()) # vim: tabstop=4 expandtab shiftwidth=4