# HG changeset patch # User Paul Boddie # Date 1441037371 -7200 # Node ID d98222e97d5e75b144191bfe5875955071a19e6d # Parent 9356528e54d7d4506bffb764a0e1255d9c8be4f6 Renamed the scheduling_resolution setting to permitted_times, adding some documentation for the setting. Renamed various names in the code to reflect the renamed setting. diff -r 9356528e54d7 -r d98222e97d5e docs/preferences.txt --- a/docs/preferences.txt Mon Aug 31 15:44:46 2015 +0200 +++ b/docs/preferences.txt Mon Aug 31 18:09:31 2015 +0200 @@ -54,11 +54,14 @@ Define how incoming event messages are delivered to recipients: - * message-only (deliver only the incoming message as it was received) - * message-then-summary (deliver the message first followed by a summary - message) - * summary-then-message (deliver a summary first followed by the message) - * summary-only (deliver only a summary of the message) + message-only deliver only the incoming message as it was received + + message-then-summary deliver the message first followed by a summary + message + + summary-then-message deliver a summary first followed by the message + + summary-only deliver only a summary of the message participating ------------- @@ -72,3 +75,31 @@ recipients will be handled in other ways. Thus, initial non-participation must be defined by initialising this setting to "no" for all eligible users, if this is the general policy on initial calendar system participation. + +permitted_times +--------------- + +Default: (none) +Alternatives: (see below) + +Define the time values at which events can be scheduled. In its simplest form, +this indicates the resolution of a calendar for a participant supporting this +setting, with the given minute values being those allowed for the start and +end of an event. This setting requires a value of one of the following forms: + + + : + :: + +Each list of values is a comma-separated collection of permissible values for +the unit of time being constrained. Any unspecified list is taken to permit +all normally permissible values for that unit of time. For example: + + 0,15,30,45 every 15 minutes from the start of each hour + 10,12,14,16:0,20,40 every 20 minutes from 10:00 until 16:40 inclusive + 12::0,30 every 30 seconds from the start of each minute during + the period from 12:00:00 until 12:59:30 inclusive + +The purpose of this setting is not necessarily to impose availability +constraints but instead to impose a "grid" to which event start and end points +shall be "locked". diff -r 9356528e54d7 -r d98222e97d5e imiptools/client.py --- a/imiptools/client.py Mon Aug 31 15:44:46 2015 +0200 +++ b/imiptools/client.py Mon Aug 31 18:09:31 2015 +0200 @@ -24,7 +24,7 @@ from imiptools.data import Object, get_address, get_uri, get_window_end, \ is_new_object, make_freebusy, to_part, \ uri_dict, uri_items, uri_values -from imiptools.dates import check_resolution, format_datetime, get_default_timezone, \ +from imiptools.dates import check_permitted_values, format_datetime, get_default_timezone, \ get_timestamp, to_timezone from imiptools.period import can_schedule, remove_period, \ remove_additional_periods, remove_affected_period, \ @@ -89,7 +89,7 @@ def have_manager(self): return MANAGER_INTERFACE - def get_scheduling_resolution(self): + def get_permitted_values(self): """ Decode a specification of one of the following forms... @@ -102,11 +102,11 @@ """ prefs = self.get_preferences() - resolution = prefs and prefs.get("scheduling_resolution") - if resolution: + permitted_values = prefs and prefs.get("permitted_times") + if permitted_values: try: l = [] - for component in resolution.split(":")[:3]: + for component in permitted_values.split(":")[:3]: if component: l.append(map(int, component.split(","))) else: @@ -424,8 +424,8 @@ "Check the object against any scheduling constraints." - resolution = self.get_scheduling_resolution() - if not resolution: + permitted_values = self.get_permitted_values() + if not permitted_values: return None invalid = [] @@ -433,8 +433,8 @@ for period in self.obj.get_periods(self.get_tzid()): start = period.get_start() end = period.get_end() - start_errors = check_resolution(start, resolution) - end_errors = check_resolution(end, resolution) + start_errors = check_permitted_values(start, permitted_values) + end_errors = check_permitted_values(end, permitted_values) if start_errors or end_errors: invalid.append((period.origin, start_errors, end_errors)) @@ -444,8 +444,8 @@ "Correct the object according to any scheduling constraints." - resolution = self.get_scheduling_resolution() - return resolution and self.obj.correct_object(self.get_tzid(), resolution) + permitted_values = self.get_permitted_values() + return permitted_values and self.obj.correct_object(self.get_tzid(), permitted_values) # Object retrieval. diff -r 9356528e54d7 -r d98222e97d5e imiptools/data.py --- a/imiptools/data.py Mon Aug 31 15:44:46 2015 +0200 +++ b/imiptools/data.py Mon Aug 31 18:09:31 2015 +0200 @@ -22,7 +22,7 @@ from bisect import bisect_left from datetime import date, datetime, timedelta from email.mime.text import MIMEText -from imiptools.dates import check_resolution, correct_datetime, \ +from imiptools.dates import check_permitted_values, correct_datetime, \ format_datetime, get_datetime, \ get_datetime_item as get_item_from_datetime, \ get_datetime_tzid, \ @@ -396,7 +396,7 @@ return old_values != set(self.get_date_values("RDATE")) - def correct_object(self, tzid, resolution): + def correct_object(self, tzid, permitted_values): "Correct the object's period details." @@ -406,8 +406,8 @@ for period in self.get_periods(tzid): start = period.get_start() end = period.get_end() - start_errors = check_resolution(start, resolution) - end_errors = check_resolution(end, resolution) + start_errors = check_permitted_values(start, permitted_values) + end_errors = check_permitted_values(end, permitted_values) if not (start_errors or end_errors): if period.origin == "RDATE": @@ -415,9 +415,9 @@ continue if start_errors: - start = correct_datetime(start, resolution) + start = correct_datetime(start, permitted_values) if end_errors: - end = correct_datetime(end, resolution) + end = correct_datetime(end, permitted_values) period = RecurringPeriod(start, end, period.tzid, period.origin, period.get_start_attr(), period.get_end_attr()) if period.origin == "DTSTART": diff -r 9356528e54d7 -r d98222e97d5e imiptools/dates.py --- a/imiptools/dates.py Mon Aug 31 15:44:46 2015 +0200 +++ b/imiptools/dates.py Mon Aug 31 18:09:31 2015 +0200 @@ -476,14 +476,14 @@ class ValidityError(Exception): pass -def check_resolution(dt, resolution): +def check_permitted_values(dt, permitted_values): - "Check the datetime 'dt' against the 'resolution' list." + "Check the datetime 'dt' against the 'permitted_values' list." if not isinstance(dt, datetime): raise ValidityError - hours, minutes, seconds = resolution + hours, minutes, seconds = permitted_values errors = [] if hours and dt.hour not in hours: @@ -495,19 +495,19 @@ return errors -def correct_datetime(dt, resolution): +def correct_datetime(dt, permitted_values): - "Correct 'dt' using the given 'resolution' details." + "Correct 'dt' using the given 'permitted_values' details." - carry, hour, minute, second = correct_value((dt.hour, dt.minute, dt.second), resolution) + carry, hour, minute, second = correct_value((dt.hour, dt.minute, dt.second), permitted_values) return datetime(dt.year, dt.month, dt.day, hour, minute, second, dt.microsecond, dt.tzinfo) + \ (carry and timedelta(1) or timedelta(0)) -def correct_value(value, resolution): +def correct_value(value, permitted_values): """ Correct the given (hour, minute, second) tuple 'value' according to the - 'resolution' details. + 'permitted_values' details. """ limits = 23, 59, 59 @@ -517,7 +517,7 @@ # Find invalid values and reset all following values. - for v, values, limit in zip(value, resolution, limits): + for v, values, limit in zip(value, permitted_values, limits): if reset: if values: v = values[0] @@ -537,7 +537,7 @@ # significant values if the next valid value is the first in the appropriate # series. - for v, values, limit in zip(value, resolution, limits)[::-1]: + for v, values, limit in zip(value, permitted_values, limits)[::-1]: if carry: v += 1 if v > limit: diff -r 9356528e54d7 -r d98222e97d5e tests/test_resource_invitation_constraints.sh --- a/tests/test_resource_invitation_constraints.sh Mon Aug 31 15:44:46 2015 +0200 +++ b/tests/test_resource_invitation_constraints.sh Mon Aug 31 18:09:31 2015 +0200 @@ -21,7 +21,7 @@ mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" echo 'share' > "$PREFS/$USER/freebusy_sharing" -echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/scheduling_resolution" +echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times" "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ | "$SHOWMAIL" \