1.1 --- a/imiptools/__init__.py Tue Jan 31 15:49:14 2017 +0100
1.2 +++ b/imiptools/__init__.py Tue Jan 31 15:53:41 2017 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 A processing framework for iMIP content.
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 email import message_from_file
1.16 -from imiptools import config
1.17 +from imiptools.config import settings
1.18 from imiptools.client import Client
1.19 from imiptools.content import handle_itip_part
1.20 from imiptools.data import get_address, get_addresses, get_uri
1.21 @@ -106,7 +106,7 @@
1.22 # None and deduced from the object content later.
1.23
1.24 else:
1.25 - senders = [sender for sender in get_addresses(get_all_values(msg, "From") or []) if sender != config.MESSAGE_SENDER]
1.26 + senders = [sender for sender in get_addresses(get_all_values(msg, "From") or []) if sender != settings["MESSAGE_SENDER"]]
1.27 Recipient(senders and senders[0] or None, messenger, store, publisher, journal, preferences_dir, self.handlers, self.outgoing_only, self.debug
1.28 ).process(msg, senders)
1.29
1.30 @@ -189,7 +189,7 @@
1.31 getvalue = lambda value, default=None: value and value[0] or default
1.32
1.33 self.messenger = Messenger(lmtp_socket=getvalue(lmtp), local_smtp=local_smtp, sender=getvalue(senders))
1.34 - self.store_type = getvalue(store_type, config.STORE_TYPE)
1.35 + self.store_type = getvalue(store_type, settings["STORE_TYPE"])
1.36 self.store_dir = getvalue(store_dir)
1.37 self.publishing_dir = getvalue(publishing_dir)
1.38 self.preferences_dir = getvalue(preferences_dir)
1.39 @@ -198,7 +198,7 @@
1.40 # If debug mode is set, extend the line length for convenience.
1.41
1.42 if self.debug:
1.43 - config.CALENDAR_LINE_LENGTH = 1000
1.44 + settings["CALENDAR_LINE_LENGTH"] = 1000
1.45
1.46 # Process the input.
1.47
1.48 @@ -381,7 +381,7 @@
1.49 # Determine whether to wrap, accompany or replace the message.
1.50
1.51 prefs = self.get_preferences()
1.52 - incoming = prefs.get("incoming", config.INCOMING_DEFAULT)
1.53 + incoming = prefs.get("incoming", settings["INCOMING_DEFAULT"])
1.54
1.55 if incoming == "message-only":
1.56 messages = [msg]
2.1 --- a/imiptools/client.py Tue Jan 31 15:49:14 2017 +0100
2.2 +++ b/imiptools/client.py Tue Jan 31 15:53:41 2017 +0100
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Common calendar client utilities.
2.6
2.7 -Copyright (C) 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -20,7 +20,7 @@
2.13 """
2.14
2.15 from datetime import datetime, timedelta
2.16 -from imiptools import config
2.17 +from imiptools.config import settings
2.18 from imiptools.data import Object, check_delegation, get_address, get_uri, \
2.19 get_window_end, is_new_object, make_freebusy, \
2.20 make_uid, to_part, uri_dict, uri_item, uri_items, \
2.21 @@ -50,11 +50,11 @@
2.22
2.23 self.user = user
2.24 self.messenger = messenger
2.25 - self.store = store or get_store(config.STORE_TYPE, config.STORE_DIR)
2.26 - self.journal = journal or get_journal(config.STORE_TYPE, config.JOURNAL_DIR)
2.27 + self.store = store or get_store(settings["STORE_TYPE"], settings["STORE_DIR"])
2.28 + self.journal = journal or get_journal(settings["STORE_TYPE"], settings["JOURNAL_DIR"])
2.29
2.30 try:
2.31 - self.publisher = publisher or get_publisher(config.PUBLISH_DIR)
2.32 + self.publisher = publisher or get_publisher(settings["PUBLISH_DIR"])
2.33 except OSError:
2.34 self.publisher = None
2.35
2.36 @@ -120,56 +120,56 @@
2.37 "Return participation in the calendar system."
2.38
2.39 prefs = self.get_preferences()
2.40 - return prefs and prefs.get("participating", config.PARTICIPATING_DEFAULT) != "no" or False
2.41 + return prefs and prefs.get("participating", settings["PARTICIPATING_DEFAULT"]) != "no" or False
2.42
2.43 def is_sharing(self):
2.44
2.45 "Return whether free/busy information is being generally shared."
2.46
2.47 prefs = self.get_preferences()
2.48 - return prefs and prefs.get("freebusy_sharing", config.SHARING_DEFAULT) == "share" or False
2.49 + return prefs and prefs.get("freebusy_sharing", settings["SHARING_DEFAULT"]) == "share" or False
2.50
2.51 def is_bundling(self):
2.52
2.53 "Return whether free/busy information is being bundled in messages."
2.54
2.55 prefs = self.get_preferences()
2.56 - return prefs and prefs.get("freebusy_bundling", config.BUNDLING_DEFAULT) == "always" or False
2.57 + return prefs and prefs.get("freebusy_bundling", settings["BUNDLING_DEFAULT"]) == "always" or False
2.58
2.59 def is_notifying(self):
2.60
2.61 "Return whether recipients are notified about free/busy payloads."
2.62
2.63 prefs = self.get_preferences()
2.64 - return prefs and prefs.get("freebusy_messages", config.NOTIFYING_DEFAULT) == "notify" or False
2.65 + return prefs and prefs.get("freebusy_messages", settings["NOTIFYING_DEFAULT"]) == "notify" or False
2.66
2.67 def is_publishing(self):
2.68
2.69 "Return whether free/busy information is being published as Web resources."
2.70
2.71 prefs = self.get_preferences()
2.72 - return prefs and prefs.get("freebusy_publishing", config.PUBLISHING_DEFAULT) == "publish" or False
2.73 + return prefs and prefs.get("freebusy_publishing", settings["PUBLISHING_DEFAULT"]) == "publish" or False
2.74
2.75 def is_refreshing(self):
2.76
2.77 "Return whether a recipient supports requests to refresh event details."
2.78
2.79 prefs = self.get_preferences()
2.80 - return prefs and prefs.get("event_refreshing", config.REFRESHING_DEFAULT) == "always" or False
2.81 + return prefs and prefs.get("event_refreshing", settings["REFRESHING_DEFAULT"]) == "always" or False
2.82
2.83 def allow_add(self):
2.84 return self.get_add_method_response() in ("add", "refresh")
2.85
2.86 def get_add_method_response(self):
2.87 prefs = self.get_preferences()
2.88 - return prefs and prefs.get("add_method_response", config.ADD_RESPONSE_DEFAULT) or "refresh"
2.89 + return prefs and prefs.get("add_method_response", settings["ADD_RESPONSE_DEFAULT"]) or "refresh"
2.90
2.91 def get_offer_period(self):
2.92
2.93 "Decode a specification in the iCalendar duration format."
2.94
2.95 prefs = self.get_preferences()
2.96 - duration = prefs and prefs.get("freebusy_offers", config.FREEBUSY_OFFER_DEFAULT)
2.97 + duration = prefs and prefs.get("freebusy_offers", settings["FREEBUSY_OFFER_DEFAULT"])
2.98
2.99 # NOTE: Should probably report an error somehow if None.
2.100
2.101 @@ -177,10 +177,10 @@
2.102
2.103 def get_organiser_replacement(self):
2.104 prefs = self.get_preferences()
2.105 - return prefs and prefs.get("organiser_replacement", config.ORGANISER_REPLACEMENT_DEFAULT) or "attendee"
2.106 + return prefs and prefs.get("organiser_replacement", settings["ORGANISER_REPLACEMENT_DEFAULT"]) or "attendee"
2.107
2.108 def have_manager(self):
2.109 - return config.MANAGER_INTERFACE
2.110 + return settings["MANAGER_INTERFACE"]
2.111
2.112 def get_permitted_values(self):
2.113
2.114 @@ -307,13 +307,13 @@
2.115
2.116 "Return an encoded MIME part for the given 'method' and 'fragments'."
2.117
2.118 - return to_part(method, fragments, line_length=config.CALENDAR_LINE_LENGTH)
2.119 + return to_part(method, fragments, line_length=settings["CALENDAR_LINE_LENGTH"])
2.120
2.121 def object_to_part(self, method, obj):
2.122
2.123 "Return an encoded MIME part for the given 'method' and 'obj'."
2.124
2.125 - return obj.to_part(method, line_length=config.CALENDAR_LINE_LENGTH)
2.126 + return obj.to_part(method, line_length=settings["CALENDAR_LINE_LENGTH"])
2.127
2.128 # Preparation of messages communicating the state of events.
2.129