imip-agent

Change of imiptools/content.py

292:2d99e19c0cc3
imiptools/content.py
     1.1 --- a/imiptools/content.py	Sun Feb 08 18:39:03 2015 +0100
     1.2 +++ b/imiptools/content.py	Sun Feb 08 20:06:37 2015 +0100
     1.3 @@ -250,17 +250,36 @@
     1.4          else:
     1.5              return mapping
     1.6  
     1.7 -    def require_organiser_and_attendees(self, from_organiser=True):
     1.8 +    def require_organiser(self, from_organiser=True):
     1.9  
    1.10          """
    1.11 -        Return the organiser and attendees for the current object, filtered for
    1.12 -        the recipient of interest. Return None if no identities are eligible.
    1.13 +        Return the organiser for the current object, filtered for the sender or
    1.14 +        recipient of interest. Return None if no identities are eligible.
    1.15 +
    1.16 +        The organiser identity is normalized.
    1.17 +        """
    1.18 +
    1.19 +        organiser_item = uri_item(self.obj.get_item("ORGANIZER"))
    1.20 +
    1.21 +        # Only provide details for an organiser who sent/receives the message.
    1.22 +
    1.23 +        organiser_filter_fn = from_organiser and self.filter_by_senders or self.filter_by_recipient
    1.24  
    1.25 -        Organiser and attendee identities are provided as lower case values.
    1.26 +        if not organiser_filter_fn(dict([organiser_item])):
    1.27 +            return None
    1.28 +
    1.29 +        return organiser_item
    1.30 +
    1.31 +    def require_attendees(self, from_organiser=True):
    1.32 +
    1.33 +        """
    1.34 +        Return the attendees for the current object, filtered for the sender or
    1.35 +        recipient of interest. Return None if no identities are eligible.
    1.36 +
    1.37 +        The attendee identities are normalized.
    1.38          """
    1.39  
    1.40          attendee_map = uri_dict(self.obj.get_value_map("ATTENDEE"))
    1.41 -        organiser_item = uri_item(self.obj.get_item("ORGANIZER"))
    1.42  
    1.43          # Only provide details for attendees who sent/receive the message.
    1.44  
    1.45 @@ -270,14 +289,21 @@
    1.46          for attendee in attendee_filter_fn(attendee_map):
    1.47              attendees[attendee] = attendee_map[attendee]
    1.48  
    1.49 -        if not attendees or not organiser_item:
    1.50 -            return None
    1.51 +        return attendees
    1.52 +
    1.53 +    def require_organiser_and_attendees(self, from_organiser=True):
    1.54 +
    1.55 +        """
    1.56 +        Return the organiser and attendees for the current object, filtered for
    1.57 +        the recipient of interest. Return None if no identities are eligible.
    1.58  
    1.59 -        # Only provide details for an organiser who sent/receives the message.
    1.60 +        Organiser and attendee identities are normalized.
    1.61 +        """
    1.62  
    1.63 -        organiser_filter_fn = from_organiser and self.filter_by_senders or self.filter_by_recipient
    1.64 +        organiser_item = self.require_organiser(from_organiser)
    1.65 +        attendees = self.require_attendees(from_organiser)
    1.66  
    1.67 -        if not organiser_filter_fn(dict([organiser_item])):
    1.68 +        if not attendees or not organiser_item:
    1.69              return None
    1.70  
    1.71          return organiser_item, attendees