1.1 --- a/imiptools/handlers/scheduling/__init__.py Fri May 13 14:31:57 2016 +0200
1.2 +++ b/imiptools/handlers/scheduling/__init__.py Fri May 13 15:41:38 2016 +0200
1.3 @@ -1,7 +1,7 @@
1.4 #!/usr/bin/env python
1.5
1.6 """
1.7 -Common scheduling functionality.
1.8 +Autonomous scheduling functionality.
1.9
1.10 Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.11
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/imiptools/handlers/scheduling/common.py Fri May 13 15:41:38 2016 +0200
2.3 @@ -0,0 +1,40 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +"""
2.7 +Common scheduling functionality.
2.8 +
2.9 +Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
2.10 +
2.11 +This program is free software; you can redistribute it and/or modify it under
2.12 +the terms of the GNU General Public License as published by the Free Software
2.13 +Foundation; either version 3 of the License, or (at your option) any later
2.14 +version.
2.15 +
2.16 +This program is distributed in the hope that it will be useful, but WITHOUT
2.17 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2.18 +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2.19 +details.
2.20 +
2.21 +You should have received a copy of the GNU General Public License along with
2.22 +this program. If not, see <http://www.gnu.org/licenses/>.
2.23 +"""
2.24 +
2.25 +def standard_responses(handler, response):
2.26 +
2.27 + """
2.28 + Using 'handler' to translate descriptions, return a tuple containing the
2.29 + 'response' and a suitable description.
2.30 + """
2.31 +
2.32 + _ = handler.get_translator()
2.33 +
2.34 + if response == "ACCEPTED":
2.35 + return response, _("The recipient has scheduled the requested period.")
2.36 + elif response == "COUNTER":
2.37 + return response, _("The recipient has suggested a different period.")
2.38 + elif response == "DELEGATED":
2.39 + return response, _("The recipient has delegated the requested period.")
2.40 + else:
2.41 + return response, _("The recipient is unavailable in the requested period.")
2.42 +
2.43 +# vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/imiptools/handlers/scheduling/freebusy.py Fri May 13 14:31:57 2016 +0200
3.2 +++ b/imiptools/handlers/scheduling/freebusy.py Fri May 13 15:41:38 2016 +0200
3.3 @@ -21,6 +21,7 @@
3.4
3.5 from imiptools.data import uri_values
3.6 from imiptools.dates import ValidityError, to_timezone
3.7 +from imiptools.handlers.scheduling.common import standard_responses
3.8
3.9 def schedule_in_freebusy(handler, args, freebusy=None):
3.10
3.11 @@ -34,8 +35,6 @@
3.12 free/busy records will be used.
3.13 """
3.14
3.15 - _ = handler.get_translator()
3.16 -
3.17 # If newer than any old version, discard old details from the
3.18 # free/busy record and check for suitability.
3.19
3.20 @@ -60,8 +59,6 @@
3.21 returning an indication of the kind of response to be returned.
3.22 """
3.23
3.24 - _ = handler.get_translator()
3.25 -
3.26 obj = handler.obj.copy()
3.27
3.28 # Check any constraints on the request.
3.29 @@ -222,22 +219,6 @@
3.30 response = response == "ACCEPTED" and (changed and "COUNTER" or "ACCEPTED") or "DECLINED"
3.31 return standard_responses(handler, response)
3.32
3.33 -def standard_responses(handler, response):
3.34 -
3.35 - """
3.36 - Using 'handler' to translate descriptions, return a tuple containing the
3.37 - 'response' and a suitable description.
3.38 - """
3.39 -
3.40 - _ = handler.get_translator()
3.41 -
3.42 - if response == "ACCEPTED":
3.43 - return response, _("The recipient has scheduled the requested period.")
3.44 - elif response == "COUNTER":
3.45 - return response, _("The recipient has suggested a different period.")
3.46 - else:
3.47 - return response, _("The recipient is unavailable in the requested period.")
3.48 -
3.49 # Registry of scheduling functions.
3.50
3.51 scheduling_functions = {