1.1 --- a/tools/make_freebusy.py Fri Nov 06 13:53:32 2015 +0100
1.2 +++ b/tools/make_freebusy.py Fri Nov 06 13:54:34 2015 +0100
1.3 @@ -38,17 +38,15 @@
1.4 from imiptools.data import get_window_end, Object
1.5 from imiptools.dates import get_default_timezone, to_utc_datetime
1.6 from imiptools.period import insert_period
1.7 -from imiptools.profile import Preferences
1.8 from imip_store import FileStore, FilePublisher
1.9
1.10 -def make_freebusy(store, publisher, preferences, user, participant,
1.11 - store_and_publish, include_needs_action, reset_updated_list, verbose):
1.12 +def make_freebusy(client, participant, store_and_publish, include_needs_action,
1.13 + reset_updated_list, verbose):
1.14
1.15 """
1.16 - Using the given 'store', 'publisher' and 'preferences', make free/busy
1.17 - details for the records of the given 'user', generating details for
1.18 - 'participant' if not indicated as None; otherwise, generating free/busy
1.19 - details concerning the given user.
1.20 + Using the given 'client' representing a user, make free/busy details for the
1.21 + records of the user, generating details for 'participant' if not indicated
1.22 + as None; otherwise, generating free/busy details concerning the given user.
1.23
1.24 If 'store_and_publish' is set, the stored details will be updated;
1.25 otherwise, the details will be written to standard output.
1.26 @@ -64,6 +62,11 @@
1.27 If 'verbose' is set, messages will be written to standard error.
1.28 """
1.29
1.30 + user = client.user
1.31 + store = client.get_store()
1.32 + publisher = client.get_publisher()
1.33 + preferences = client.get_preferences()
1.34 +
1.35 participant = participant or user
1.36 tzid = preferences.get("TZID") or get_default_timezone()
1.37
1.38 @@ -120,7 +123,7 @@
1.39 if user == participant:
1.40 store.set_freebusy(user, fb)
1.41
1.42 - if Client(user).is_sharing() and Client(user).is_publishing():
1.43 + if client.is_sharing() and client.is_publishing():
1.44 publisher.set_freebusy(user, fb)
1.45
1.46 # Update the list of objects providing periods on future occasions.
1.47 @@ -179,6 +182,12 @@
1.48 Specify -n to include objects with PARTSTAT of NEEDS-ACTION.
1.49 Specify -r to inspect all objects, not just those expected to provide details.
1.50 Specify -v for additional messages on standard error.
1.51 +
1.52 +General options:
1.53 +
1.54 +-S indicate the store directory location
1.55 +-P indicate the publishing directory location
1.56 +-p indicate the preferences directory location
1.57 """ % split(sys.argv[0])[1]
1.58 sys.exit(1)
1.59
1.60 @@ -200,7 +209,6 @@
1.61
1.62 store = FileStore(store_dir)
1.63 publisher = FilePublisher(publishing_dir)
1.64 - preferences = Preferences(user, preferences_dir)
1.65
1.66 # Obtain a list of users for processing.
1.67
1.68 @@ -214,7 +222,8 @@
1.69 for user in users:
1.70 if verbose:
1.71 print >>sys.stderr, user
1.72 - make_freebusy(store, publisher, preferences, user, participant,
1.73 + make_freebusy(
1.74 + Client(user, None, store, publisher, preferences_dir), participant,
1.75 store_and_publish, include_needs_action, reset_updated_list, verbose)
1.76
1.77 # vim: tabstop=4 expandtab shiftwidth=4