Example #1
0
        def do(event):
            if recurrence_id:
                return
            add_recurrence = not all_empty(record, 'rdate', 'rrule')
            recurrence_installed = Recurrence.installed_on(event.item)
            if not recurrence_installed and not add_recurrence:
                pass  # no recurrence, nothing to do
            elif recurrence_id:
                pass  # modification, no rules to set
            else:
                recur = Recurrence(event.item)
                if add_recurrence and not recurrence_installed:
                    recur.add()
                for datetype in 'rdate', 'exdate':
                    record_field = getattr(record, datetype)
                    if record_field is not eim.NoChange:
                        if record_field is None:
                            dates = ()
                        else:
                            dates = fromICalendarDateTime(record_field,
                                                          multivalued=True)[0]
                        date_set = getattr(recur, datetype + 's')
                        if date_set.symmetric_difference(dates):
                            date_set.clear()
                            date_set.update(dates)

                if record.rrule is not eim.NoChange:
                    if record.rrule in emptyValues:
                        recur.frequency = None
                    else:
                        # EIM serializes multiple RRULEs colon separated,
                        # ignoring all but the first for now.
                        rule_dict = {}
                        first_rule, sep, later_rules = record.rrule.upper(
                        ).partition(':')
                        for key_value_string in first_rule.split(';'):
                            key, sep, value = key_value_string.partition('=')
                            rule_dict[key] = value

                        # count and until are mutually exclusive, special case
                        if 'COUNT' in rule_dict:
                            recur.count = int(rule_dict['COUNT'])
                        elif 'UNTIL' in rule_dict:
                            recur.until = fromICalendarDateTime(
                                rule_dict['UNTIL'])[0]
                        else:
                            recur.until = None

                        for attr, tup in rrule_attr_dispatch.items():
                            rule_key, convert = tup
                            if rule_key in rule_dict:
                                setattr(recur, attr,
                                        convert(rule_dict[rule_key]))
                            else:
                                reset_cell_default(recur, attr)

                if not recur.frequency and not recur.rdates:
                    if recurrence_installed:
                        recur.remove()
Example #2
0
        def do(event):
            if recurrence_id:
                return
            add_recurrence = not all_empty(record, 'rdate', 'rrule')
            recurrence_installed = Recurrence.installed_on(event.item)
            if not recurrence_installed and not add_recurrence:
                pass # no recurrence, nothing to do
            elif recurrence_id:
                pass # modification, no rules to set
            else:
                recur = Recurrence(event.item)
                if add_recurrence and not recurrence_installed:
                    recur.add()
                for datetype in 'rdate', 'exdate':
                    record_field = getattr(record, datetype)
                    if record_field is not eim.NoChange:
                        if record_field is None:
                            dates = ()
                        else:
                            dates = fromICalendarDateTime(record_field, multivalued=True)[0]
                        date_set = getattr(recur, datetype + 's')
                        if date_set.symmetric_difference(dates):
                            date_set.clear()
                            date_set.update(dates)

                if record.rrule is not eim.NoChange:
                    if record.rrule in emptyValues:
                        recur.frequency = None
                    else:
                        # EIM serializes multiple RRULEs colon separated,
                        # ignoring all but the first for now.
                        rule_dict = {}
                        first_rule, sep, later_rules = record.rrule.upper().partition(':')
                        for key_value_string in first_rule.split(';'):
                            key, sep, value = key_value_string.partition('=')
                            rule_dict[key] = value

                        # count and until are mutually exclusive, special case
                        if 'COUNT' in rule_dict:
                            recur.count = int(rule_dict['COUNT'])
                        elif 'UNTIL' in rule_dict:
                            recur.until = fromICalendarDateTime(rule_dict['UNTIL'])[0]
                        else:
                            recur.until = None

                        for attr, tup in rrule_attr_dispatch.items():
                            rule_key, convert = tup
                            if rule_key in rule_dict:
                                setattr(recur, attr, convert(rule_dict[rule_key]))
                            else:
                                reset_cell_default(recur, attr)

                if not recur.frequency and not recur.rdates:
                    if recurrence_installed:
                        recur.remove()
Example #3
0
        def do(reminder_list):
            # Rather than simply leaving out a DisplayAlarmRecord, we're using
            # a trigger value of None to indicate there is no alarm:
            if record.trigger is None:
                if reminder_list.reminders:
                    reminder_list.reminders[:] = []
                return
            elif all_empty(record, 'trigger', 'description'):
                # no changes we understand
                return

            if reminder_list.reminders:
                reminder = reminder_list.reminders[0]
            else:
                reminder = reminder_list.add_reminder()

            # trigger may be a delta, or a datetime
            if record.trigger not in noChangeOrInherit:
                try:
                    val = fromICalendarDateTime(record.trigger)[0]
                    reminder.fixed_trigger = val.astimezone(TimeZone.default)
                except:
                    try:
                        reminder.delta = stringToDurations(record.trigger)[0]
                    except:
                        pass

            if (record.description not in noChangeOrInherit and
                record.description is not None):
                reminder.description = record.description
Example #4
0
        def do(reminder_list):
            # Rather than simply leaving out a DisplayAlarmRecord, we're using
            # a trigger value of None to indicate there is no alarm:
            if record.trigger is None:
                if reminder_list.reminders:
                    reminder_list.reminders[:] = []
                return
            elif all_empty(record, 'trigger', 'description'):
                # no changes we understand
                return

            if reminder_list.reminders:
                reminder = reminder_list.reminders[0]
            else:
                reminder = reminder_list.add_reminder()

            # trigger may be a delta, or a datetime
            if record.trigger not in noChangeOrInherit:
                try:
                    val = fromICalendarDateTime(record.trigger)[0]
                    reminder.fixed_trigger = val.astimezone(TimeZone.default)
                except:
                    try:
                        reminder.delta = stringToDurations(record.trigger)[0]
                    except:
                        pass

            if (record.description not in noChangeOrInherit
                    and record.description is not None):
                reminder.description = record.description
Example #5
0
def format_event_dtstart(field, value):
    start, allDay, anyTime = fromICalendarDateTime(value)
    s = str(start)
    if allDay:
        s = "%s (all day)" % s
    if anyTime:
        s = "%s (any time)" % s
    return s
Example #6
0
def format_event_dtstart(field, value):
    start, allDay, anyTime = fromICalendarDateTime(value)
    s = str(start)
    if allDay:
        s = "%s (all day)" % s
    if anyTime:
        s = "%s (any time)" % s
    return s
Example #7
0
def getTimeValues(record):
    """
    Extract start time and allDay/anyTime from a record.
    """
    dtstart  = record.dtstart
    # tolerate empty dtstart, treat it as Inherit, bug 9849
    if dtstart is None:
        dtstart = eim.Inherit
    start = None
    if dtstart not in noChangeOrInherit:
        start, allDay, anyTime = fromICalendarDateTime(dtstart)
    else:
        allDay = anyTime = start = dtstart
    # anyTime should be set to True if allDay is true, bug 9041
    anyTime = anyTime or allDay
    return (start, allDay, anyTime)
Example #8
0
def getTimeValues(record):
    """
    Extract start time and allDay/anyTime from a record.
    """
    dtstart = record.dtstart
    # tolerate empty dtstart, treat it as Inherit, bug 9849
    if dtstart is None:
        dtstart = eim.Inherit
    start = None
    if dtstart not in noChangeOrInherit:
        start, allDay, anyTime = fromICalendarDateTime(dtstart)
    else:
        allDay = anyTime = start = dtstart
    # anyTime should be set to True if allDay is true, bug 9041
    anyTime = anyTime or allDay
    return (start, allDay, anyTime)