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 smart_setattr(self, val, ob, attr):
     if val is Inherit:
         reset_cell_default(ob, attr)
     elif val is not NoChange:
         setattr(ob, attr, val)
Example #4
0
 def smart_setattr(self, val, ob, attr):
     if val is Inherit:
         reset_cell_default(ob, attr)
     elif val is not NoChange:
         setattr(ob, attr, val)