Extract the recipients from the message object given.
779450
def _extract_recipients(
    message: Message, resent_dates: List[Union[str, Header]] = None
) -> List[str]:
    
    recipients = []  # type: List[str]

    if resent_dates:
        recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc")
    else:
        recipient_headers = ("To", "Cc", "Bcc")

    for header in recipient_headers:
        recipients.extend(message.get_all(header, []))  # type: ignore

    parsed_recipients = [
        str(email.utils.formataddr(address))
        for address in email.utils.getaddresses(recipients)
    ]

    return parsed_recipients
877485
def get_recipients(self, name):
        
        to_str = self.render_string(self.data[name])
        formatted_emails = [
            email.utils.formataddr(addr_pair)
            for addr_pair in email.utils.getaddresses([to_str])
        ]
        return [i for i in formatted_emails if i]
595357
private static List<String> convert(List<Recipient> recipients) throws PhoneNumberException {
		List<String> tos = new ArrayList<>(recipients.size());
		// convert phone numbers to international format
		for (Recipient recipient : recipients) {
			tos.add(toInternational(recipient.getPhoneNumber()));
		}
		return tos;
	}
586708
function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
	      var visitor = new _Visitor(implicitTags, implicitAttrs);
	      return visitor.extract(nodes, interpolationConfig);
	  }
264369
protected function loadMessages()
    {
        $messages = Collection::make($this->event->get('messaging'))->filter(function ($msg) {
            return isset($msg['message']) && isset($msg['message']['attachments']) && isset($msg['message']['attachments']);
        })->transform(function ($msg) {
            $message = new IncomingMessage(Location::PATTERN, $msg['sender']['id'], $msg['recipient']['id'], $msg);
            $message->setLocation($this->getLocation($msg));

            return $message;
        })->toArray();

        if (count($messages) === 0) {
            $messages = [new IncomingMessage('', '', '')];
        }

        $this->messages = $messages;
    }
695269
def parse_info_recipients(header, reference_id=None):
    
    m = _INFO_PATTERN.search(header)
    if not m:
        return []
    to_header = m.group(1)
    return _route_recipient_from_header(to_header, reference_id)
1299788
def get_addresses(message: list) -> list:
    
    # Need the address so that we know who to send the message back to
    addresses = []
    for address in message:
        # if we hit a blank string, then we've got all the addresses
        if address == b'':
            break
        addresses.append(address)

    return addresses
856453
def get_messages(self):
        
        if not self._messages:  # if not already cached
            query = self._dbman.query('thread:' + self._id)
            thread = next(query.search_threads())

            def accumulate(acc, msg):
                M = Message(self._dbman, msg, thread=self)
                acc[M] = []
                r = msg.get_replies()
                if r is not None:
                    for m in r:
                        acc[M].append(accumulate(acc, m))
                return M

            self._messages = {}
            for m in thread.get_toplevel_messages():
                self._toplevel_messages.append(accumulate(self._messages, m))
        return self._messages
951030
def decode(self, msg):
        """"""
        _check_message_valid(msg)
        cmd = msg[2:4]
        decoder = getattr(self, '_{}_decode'.format(cmd.lower()), None)
        if not decoder:
            cmd = 'unknown'
            decoder = self._unknown_decode
        decoded_msg = decoder(msg)
        for handler in self._handlers.get(cmd, []):
            handler(**decoded_msg)
402894
def parse_headers(cls, msg):
        
        return list(email.parser.Parser().parsestr(msg).items())
518183
def get_subject(self, msg):
        """"""

        text, encoding = decode_header(msg['subject'])[-1]

        try:
            text = text.decode(encoding)

        # If it's already decoded, ignore error
        except AttributeError:
            pass

        return text
1199529
public Message message(String subject, String messageBody, Map<String, Object> attributes) {
        Collection<Member> recipients = new ArrayList<Member>();
        return message(subject, messageBody, recipients, attributes);
    }
619270
def from_mime(cls, message, manager):
        
        text, html, attachments = deconstruct_multipart(message)
        subject = prepare_header(message["Subject"])
        sender = prepare_header(message["From"])
        to = prepare_header(message["To"])
        cc = prepare_header(message["Cc"])
        bcc = prepare_header(message["Bcc"])
        reply_to = prepare_header(message["Reply-To"])
        tag = getattr(message, "tag", None)
        return cls(
            manager=manager,
            From=sender,
            To=to,
            TextBody=text,
            HtmlBody=html,
            Subject=subject,
            Cc=cc,
            Bcc=bcc,
            ReplyTo=reply_to,
            Attachments=attachments,
            Tag=tag,
        )
830147
def extract_objects_from_source(self, text, type_filter=None):
    '''
    '''
    objects = parse_verilog(text)

    if type_filter:
      objects = [o for o in objects if isinstance(o, type_filter)]

    return objects
214150
def receive(
            self,
            request: RequestType,
            user: UserType = None,
            sender_key_fetcher: Callable[[str], str] = None,
            skip_author_verification: bool = False) -> Tuple[str, str]:
        """"""
        self.user = user
        self.get_contact_key = sender_key_fetcher
        self.store_magic_envelope_doc(request.body)
        # Open payload and get actual message
        self.content = self.get_message_content()
        # Get sender handle
        self.sender_handle = self.get_sender()
        # Verify the message is from who it claims to be
        if not skip_author_verification:
            self.verify_signature()
        return self.sender_handle, self.content
805512
def serialize_email_messages(messages: List[EmailMessage]):
    
    return [
        base64.b64encode(zlib.compress(pickle.dumps(m, protocol=4))).decode()
        for m in messages
    ]
625990
def _filter_messages(messages, products=None, levels=None):
    """"""
    if products is None:
        products = []
    if levels is None:
        levels = []
    segments = []
    bounds = len(messages)
    for i, message in enumerate(messages):
        if (message[3] in products or len(products) == 0) and \
                (message[4] in levels or len(levels) == 0):
            start = int(message[1])
            if i == (bounds - 1):
                end = None
            else:
                end = int(messages[i+1][1])
            segments.append((start, end))
    return _join(segments)