1.1 --- a/imiptools/client.py Tue Jan 31 15:49:14 2017 +0100
1.2 +++ b/imiptools/client.py Tue Jan 31 15:53:41 2017 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Common calendar client utilities.
1.6
1.7 -Copyright (C) 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -20,7 +20,7 @@
1.13 """
1.14
1.15 from datetime import datetime, timedelta
1.16 -from imiptools import config
1.17 +from imiptools.config import settings
1.18 from imiptools.data import Object, check_delegation, get_address, get_uri, \
1.19 get_window_end, is_new_object, make_freebusy, \
1.20 make_uid, to_part, uri_dict, uri_item, uri_items, \
1.21 @@ -50,11 +50,11 @@
1.22
1.23 self.user = user
1.24 self.messenger = messenger
1.25 - self.store = store or get_store(config.STORE_TYPE, config.STORE_DIR)
1.26 - self.journal = journal or get_journal(config.STORE_TYPE, config.JOURNAL_DIR)
1.27 + self.store = store or get_store(settings["STORE_TYPE"], settings["STORE_DIR"])
1.28 + self.journal = journal or get_journal(settings["STORE_TYPE"], settings["JOURNAL_DIR"])
1.29
1.30 try:
1.31 - self.publisher = publisher or get_publisher(config.PUBLISH_DIR)
1.32 + self.publisher = publisher or get_publisher(settings["PUBLISH_DIR"])
1.33 except OSError:
1.34 self.publisher = None
1.35
1.36 @@ -120,56 +120,56 @@
1.37 "Return participation in the calendar system."
1.38
1.39 prefs = self.get_preferences()
1.40 - return prefs and prefs.get("participating", config.PARTICIPATING_DEFAULT) != "no" or False
1.41 + return prefs and prefs.get("participating", settings["PARTICIPATING_DEFAULT"]) != "no" or False
1.42
1.43 def is_sharing(self):
1.44
1.45 "Return whether free/busy information is being generally shared."
1.46
1.47 prefs = self.get_preferences()
1.48 - return prefs and prefs.get("freebusy_sharing", config.SHARING_DEFAULT) == "share" or False
1.49 + return prefs and prefs.get("freebusy_sharing", settings["SHARING_DEFAULT"]) == "share" or False
1.50
1.51 def is_bundling(self):
1.52
1.53 "Return whether free/busy information is being bundled in messages."
1.54
1.55 prefs = self.get_preferences()
1.56 - return prefs and prefs.get("freebusy_bundling", config.BUNDLING_DEFAULT) == "always" or False
1.57 + return prefs and prefs.get("freebusy_bundling", settings["BUNDLING_DEFAULT"]) == "always" or False
1.58
1.59 def is_notifying(self):
1.60
1.61 "Return whether recipients are notified about free/busy payloads."
1.62
1.63 prefs = self.get_preferences()
1.64 - return prefs and prefs.get("freebusy_messages", config.NOTIFYING_DEFAULT) == "notify" or False
1.65 + return prefs and prefs.get("freebusy_messages", settings["NOTIFYING_DEFAULT"]) == "notify" or False
1.66
1.67 def is_publishing(self):
1.68
1.69 "Return whether free/busy information is being published as Web resources."
1.70
1.71 prefs = self.get_preferences()
1.72 - return prefs and prefs.get("freebusy_publishing", config.PUBLISHING_DEFAULT) == "publish" or False
1.73 + return prefs and prefs.get("freebusy_publishing", settings["PUBLISHING_DEFAULT"]) == "publish" or False
1.74
1.75 def is_refreshing(self):
1.76
1.77 "Return whether a recipient supports requests to refresh event details."
1.78
1.79 prefs = self.get_preferences()
1.80 - return prefs and prefs.get("event_refreshing", config.REFRESHING_DEFAULT) == "always" or False
1.81 + return prefs and prefs.get("event_refreshing", settings["REFRESHING_DEFAULT"]) == "always" or False
1.82
1.83 def allow_add(self):
1.84 return self.get_add_method_response() in ("add", "refresh")
1.85
1.86 def get_add_method_response(self):
1.87 prefs = self.get_preferences()
1.88 - return prefs and prefs.get("add_method_response", config.ADD_RESPONSE_DEFAULT) or "refresh"
1.89 + return prefs and prefs.get("add_method_response", settings["ADD_RESPONSE_DEFAULT"]) or "refresh"
1.90
1.91 def get_offer_period(self):
1.92
1.93 "Decode a specification in the iCalendar duration format."
1.94
1.95 prefs = self.get_preferences()
1.96 - duration = prefs and prefs.get("freebusy_offers", config.FREEBUSY_OFFER_DEFAULT)
1.97 + duration = prefs and prefs.get("freebusy_offers", settings["FREEBUSY_OFFER_DEFAULT"])
1.98
1.99 # NOTE: Should probably report an error somehow if None.
1.100
1.101 @@ -177,10 +177,10 @@
1.102
1.103 def get_organiser_replacement(self):
1.104 prefs = self.get_preferences()
1.105 - return prefs and prefs.get("organiser_replacement", config.ORGANISER_REPLACEMENT_DEFAULT) or "attendee"
1.106 + return prefs and prefs.get("organiser_replacement", settings["ORGANISER_REPLACEMENT_DEFAULT"]) or "attendee"
1.107
1.108 def have_manager(self):
1.109 - return config.MANAGER_INTERFACE
1.110 + return settings["MANAGER_INTERFACE"]
1.111
1.112 def get_permitted_values(self):
1.113
1.114 @@ -307,13 +307,13 @@
1.115
1.116 "Return an encoded MIME part for the given 'method' and 'fragments'."
1.117
1.118 - return to_part(method, fragments, line_length=config.CALENDAR_LINE_LENGTH)
1.119 + return to_part(method, fragments, line_length=settings["CALENDAR_LINE_LENGTH"])
1.120
1.121 def object_to_part(self, method, obj):
1.122
1.123 "Return an encoded MIME part for the given 'method' and 'obj'."
1.124
1.125 - return obj.to_part(method, line_length=config.CALENDAR_LINE_LENGTH)
1.126 + return obj.to_part(method, line_length=settings["CALENDAR_LINE_LENGTH"])
1.127
1.128 # Preparation of messages communicating the state of events.
1.129