imip-agent

Change of imiptools/client.py

619:b021078b64d4
imiptools/client.py
     1.1 --- a/imiptools/client.py	Wed Jul 29 16:40:28 2015 +0200
     1.2 +++ b/imiptools/client.py	Wed Jul 29 18:41:11 2015 +0200
     1.3 @@ -32,49 +32,6 @@
     1.4  from imiptools.profile import Preferences
     1.5  import imip_store
     1.6  
     1.7 -def update_attendees(obj, attendees, removed):
     1.8 -
     1.9 -    """
    1.10 -    Update the attendees in 'obj' with the given 'attendees' and 'removed'
    1.11 -    attendee lists. A list is returned containing the attendees whose
    1.12 -    attendance should be cancelled.
    1.13 -    """
    1.14 -
    1.15 -    to_cancel = []
    1.16 -
    1.17 -    existing_attendees = uri_values(obj.get_values("ATTENDEE") or [])
    1.18 -    added = set(attendees).difference(existing_attendees)
    1.19 -
    1.20 -    if added or removed:
    1.21 -        attendees = uri_items(obj.get_items("ATTENDEE") or [])
    1.22 -        sequence = obj.get_value("SEQUENCE")
    1.23 -
    1.24 -        if removed:
    1.25 -            remaining = []
    1.26 -
    1.27 -            for attendee, attendee_attr in attendees:
    1.28 -                if attendee in removed:
    1.29 -
    1.30 -                    # Without a sequence number, assume that the event has not
    1.31 -                    # been published and that attendees can be silently removed.
    1.32 -
    1.33 -                    if sequence is not None:
    1.34 -                        to_cancel.append((attendee, attendee_attr))
    1.35 -                else:
    1.36 -                    remaining.append((attendee, attendee_attr))
    1.37 -
    1.38 -            attendees = remaining
    1.39 -
    1.40 -        if added:
    1.41 -            for attendee in added:
    1.42 -                attendee = attendee.strip()
    1.43 -                if attendee:
    1.44 -                    attendees.append((get_uri(attendee), {"PARTSTAT" : "NEEDS-ACTION", "RSVP" : "TRUE"}))
    1.45 -
    1.46 -        obj["ATTENDEE"] = attendees
    1.47 -
    1.48 -    return to_cancel
    1.49 -
    1.50  class Client:
    1.51  
    1.52      "Common handler and manager methods."
    1.53 @@ -126,6 +83,49 @@
    1.54  
    1.55      # Common operations on calendar data.
    1.56  
    1.57 +    def update_attendees(self, obj, attendees, removed):
    1.58 +
    1.59 +        """
    1.60 +        Update the attendees in 'obj' with the given 'attendees' and 'removed'
    1.61 +        attendee lists. A list is returned containing the attendees whose
    1.62 +        attendance should be cancelled.
    1.63 +        """
    1.64 +
    1.65 +        to_cancel = []
    1.66 +
    1.67 +        existing_attendees = uri_values(obj.get_values("ATTENDEE") or [])
    1.68 +        added = set(attendees).difference(existing_attendees)
    1.69 +
    1.70 +        if added or removed:
    1.71 +            attendees = uri_items(obj.get_items("ATTENDEE") or [])
    1.72 +            sequence = obj.get_value("SEQUENCE")
    1.73 +
    1.74 +            if removed:
    1.75 +                remaining = []
    1.76 +
    1.77 +                for attendee, attendee_attr in attendees:
    1.78 +                    if attendee in removed:
    1.79 +
    1.80 +                        # Without a sequence number, assume that the event has not
    1.81 +                        # been published and that attendees can be silently removed.
    1.82 +
    1.83 +                        if sequence is not None:
    1.84 +                            to_cancel.append((attendee, attendee_attr))
    1.85 +                    else:
    1.86 +                        remaining.append((attendee, attendee_attr))
    1.87 +
    1.88 +                attendees = remaining
    1.89 +
    1.90 +            if added:
    1.91 +                for attendee in added:
    1.92 +                    attendee = attendee.strip()
    1.93 +                    if attendee:
    1.94 +                        attendees.append((get_uri(attendee), {"PARTSTAT" : "NEEDS-ACTION", "RSVP" : "TRUE"}))
    1.95 +
    1.96 +            obj["ATTENDEE"] = attendees
    1.97 +
    1.98 +        return to_cancel
    1.99 +
   1.100      def update_participation(self, obj, partstat=None):
   1.101  
   1.102          """