Return a new ``Message`` instance. The arguments are 
        passed to the ``marrow.mailer.Message`` constructor.
4298
def new(self, **kwargs):
        ''''''
        app = self.app or current_app
        mailer = app.extensions['marrowmailer']
        msg = mailer.new(**kwargs)
        msg.__class__ = Message
        return msg
71816
def create(cls, description="", message=""):
        
        instance = cls()
        instance.revision_id = make_hash_id()
        instance.release_date = datetime.datetime.now()

        if len(description) > 0:
            instance.description = description

        if len(message) > 0:
            instance.message = message

        return instance
887441
def _build_message(self, to, text, subject=None, mtype=None, unsubscribe_url=None):
        """"""
        # TODO Maybe file attachments handling through `files` message_model context var.

        if subject is None:
            subject = u'%s' % _('No Subject')

        if mtype == 'html':
            msg = self.mime_multipart()
            text_part = self.mime_multipart('alternative')
            text_part.attach(self.mime_text(strip_tags(text), _charset='utf-8'))
            text_part.attach(self.mime_text(text, 'html', _charset='utf-8'))
            msg.attach(text_part)

        else:
            msg = self.mime_text(text, _charset='utf-8')

        msg['From'] = self.from_email
        msg['To'] = to
        msg['Subject'] = subject

        if unsubscribe_url:
            msg['List-Unsubscribe'] = '<%s>' % unsubscribe_url

        return msg
1217964
def fromMessage(klass, message, op_endpoint=UNUSED):
        
        if message.isOpenID1():
            session_type = message.getArg(OPENID_NS, 'session_type')
            if session_type == 'no-encryption':
                logging.warn('Received OpenID 1 request with a no-encryption '
                            'assocaition session type. Continuing anyway.')
            elif not session_type:
                session_type = 'no-encryption'
        else:
            session_type = message.getArg(OPENID2_NS, 'session_type')
            if session_type is None:
                raise ProtocolError(message,
                                    text="session_type missing from request")

        try:
            session_class = klass.session_classes[session_type]
        except KeyError:
            raise ProtocolError(message,
                                "Unknown session type %r" % (session_type,))

        try:
            session = session_class.fromMessage(message)
        except ValueError, why:
            raise ProtocolError(message, 'Error parsing %s session: %s' %
                                (session_class.session_type, why[0]))

        assoc_type = message.getArg(OPENID_NS, 'assoc_type', 'HMAC-SHA1')
        if assoc_type not in session.allowed_assoc_types:
            fmt = 'Session type %s does not support association type %s'
            raise ProtocolError(message, fmt % (session_type, assoc_type))

        self = klass(session, assoc_type)
        self.message = message
        self.namespace = message.getOpenIDNamespace()
        return self
495730
def create_message(self, message_data, delivery_mode=None, priority=None,
                       content_type=None, content_encoding=None,
                       serializer=None):
        """"""

        delivery_mode = delivery_mode or self.delivery_mode

        # No content_type? Then we're serializing the data internally.
        if not content_type:
            serializer = serializer or self.serializer
            (content_type, content_encoding,
             message_data) = serialization.encode(message_data,
                                                  serializer=serializer)
        else:
            # If the programmer doesn't want us to serialize,
            # make sure content_encoding is set.
            if isinstance(message_data, unicode):
                if not content_encoding:
                    content_encoding = 'utf-8'
                message_data = message_data.encode(content_encoding)

            # If they passed in a string, we can't know anything
            # about it.  So assume it's binary data.
            elif not content_encoding:
                content_encoding = 'binary'

        return self.backend.prepare_message(message_data, delivery_mode,
                                            priority=priority,
                                            content_type=content_type,
                                            content_encoding=content_encoding)
1268268
def make_data(self, message):

        

        if not isinstance(message, Message):
            return message
        return message.export(self.transport_content_type)
582729
def Create(self, name):
    
    precondition.AssertType(name, Text)

    try:
      constructor = self._constructors[name]
    except KeyError:
      message = "No constructor for name '%s' has been registered"
      message %= name
      raise ValueError(message)

    instance = constructor()
    if not isinstance(instance, self._cls):
      message = ("Constructor %r for name '%s' returned instance of type %r "
                 "(expected %r)")
      message %= (constructor, name, type(instance), self._cls)
      raise TypeError(message)

    return instance
1186253
def new_message(self):
        
        msg = {}
        msg['data'] = []
        msg['type'] = self.plugin_type
        msg['source'] = self.name
        msg['ts'] = (datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()
        return msg
1176635
def send(self, message):
        
        if isinstance(message, dict):
            response = self.client.mail.send.post(request_body=message)
        else:
            response = self.client.mail.send.post(request_body=message.get())
        return response
1190412
def from_EmailMessage(cls, message):
        
        mail = cls(
            from_email=Email(message.get('From')),
            subject=message.get('Subject'),
            to_emails=Email(message.get('To')),
        )
        try:
            body = message.get_content()
        except AttributeError:
            # Python2
            body = message.get_payload()
        mail.add_content(Content(
            message.get_content_type(),
            body.strip()
        ))
        for k, v in message.items():
            mail.add_header(Header(k, v))
        return mail
219545
def send_message(self, message):
        
        with self._instance_lock:
            if message is None:
                Global.LOGGER.error("can't deliver a null messages")
                return

            if message.sender is None:
                Global.LOGGER.error(f"can't deliver anonymous messages with body {message.body}")
                return

            if message.receiver is None:
                Global.LOGGER.error(
                    f"can't deliver message from {message.sender}: recipient not specified")
                return

            if message.message is None:
                Global.LOGGER.error(f"can't deliver message with no body from {message.sender}")
                return

            sender = "*" + message.sender + "*"
            self.socket.send_multipart(
                [bytes(sender, 'utf-8'), pickle.dumps(message)])

            if Global.CONFIG_MANAGER.tracing_mode:
                Global.LOGGER.debug("dispatched : "
                                    + message.sender
                                    + "-"
                                    + message.message
                                    + "-"
                                    + message.receiver)

            self.dispatched = self.dispatched + 1
306831
def add(self, message):
        
        if not isinstance(message, ValidationMessage):
            raise TypeError("Argument must of type ValidationMessage")
        self.messages.append(message)
1055679
def create_spawnve(original_name):
    

    def new_spawnve(mode, path, args, env):
        import os
        send_process_created_message()
        return getattr(os, original_name)(mode, path, patch_args(args), env)

    return new_spawnve
778229
def from_message(bot, message):
        
        chat = message["chat"]
        return Chat(bot, chat["id"], chat["type"], message)
844525
public static AbstractMessage createInstance( byte type )
    {
        switch (type)
        {
            case EMPTY:  return new EmptyMessageImpl();
            case BYTES:  return new BytesMessageImpl();
            case MAP:    return new MapMessageImpl();
            case OBJECT: return new ObjectMessageImpl();
            case STREAM: return new StreamMessageImpl();
            case TEXT:   return new TextMessageImpl();
                
            default:
                throw new IllegalArgumentException("Unsupported message type : "+type);
        }
    }
161994
def message(message_type, payload, payload_length):
    
    return packet.build(
        Container(
            type=message_type,
            id=1,
            refer=0,
            sent=Container(
                secs=0,
                usecs=0
            ),
            recv=Container(
                secs=0,
                usecs=0
            ),
            payload_length=payload_length,
            payload=payload
        )
    )
1018466
protected function createMessage()
    {
        $message = new Message(new Swift_Message);

        // If a global from address has been specified we will set it on every message
        // instances so the developer does not have to repeat themselves every time
        // they create a new message. We will just go ahead and push the address.
        if (isset($this->from['address'])) {
            $message->from($this->from['address'], $this->from['name']);
        }

        return $message;
    }