Convert communication namedtuple to this class.

        Args:
            pub (obj): :class:`.Publication` instance which will be converted.

        Returns:
            obj: :class:`DBPublication` instance.
423118
def from_comm(cls, pub):
        '''
        
        '''
        filename = None
        if pub.b64_data:
            filename = cls._save_to_unique_filename(pub)

        return cls(
            title=pub.title,
            author=pub.author,
            pub_year=pub.pub_year,
            isbn=pub.isbn,
            urnnbn=pub.urnnbn,
            uuid=pub.uuid,
            aleph_id=pub.aleph_id,
            producent_id=pub.producent_id,
            is_public=pub.is_public,
            filename=pub.filename,
            is_periodical=pub.is_periodical,
            path=pub.path,

            file_pointer=filename
        )
26056
function PubConnection (node) {
  let connection = new EventEmitter()

  const _debug = D('dnsmq-messagebus:PUB')
  const debug = (...args) => _debug(node.name, ...args)

  let _socket = null
  let _connectingMaster = null

  /**
   * Provides a pub socket connecting to master.endpoint
   * @private
   * @param  {object} master - Map of properties about the actual master node
   * @return {object} A `zeromq` socket
   */
  const _getSocket = (master) => {
    let socket = zmq.socket('pub')
    socket._master = master
    socket.monitor(5, 0)
    socket.connect(master.endpoint)
    return socket
  }
  const _publishStream = new EventEmitter()
  _publishStream.on('message', (...args) => {
    if (_socket) _socket.send(args)
  })

  /**
   * creates a new pub socket and tries to connect it to the provided master;
   * after connection the socket is used to publish messages in the bus
   * and an eventual previous socket is closed
   * @param  {object} master
   * @return {object} the publishConnection instance
   */
  function connect (master) {
    if (_socket && _socket._master.name === master.name) {
      debug(`already connected to master ${master.name}`)
      return
    }
    if (_connectingMaster && _connectingMaster.name === master.name) {
      debug(`already connecting to master ${master.name}`)
      return
    }

    _connectingMaster = master
    let newSocket = _getSocket(master)

    let _messagesToResend = []
    let _onMessagePublished = (...args) => {
      if (_socket) _messagesToResend.push(args)
    }
    _publishStream.on('message', _onMessagePublished)

    debug(`connecting to ${master.name} at ${master.endpoint}`)

    let connectionStart = Date.now()
    const onSocketConnected = timingoutCallback((err) => {
      _publishStream.removeListener('message', _onMessagePublished)
      newSocket.unmonitor()

      if (
        err ||
        !_connectingMaster ||
        _connectingMaster.name === !master.name
      ) {
        newSocket.close()
        if (err) {
          debug(`failed to connect to ${master.name} at ${master.endpoint}`)
          disconnect()
        }
        return
      }

      _connectingMaster = null
      let previousSocket = _socket

      debug(`${previousSocket ? 'switched' : 'connected'} to ${master.name} at ${master.endpoint} in ${Date.now() - connectionStart} ms`)

      _socket = newSocket

      let totalMessagesToResend = _messagesToResend.length
      if (totalMessagesToResend) {
        debug(`resending ${totalMessagesToResend} messages published while transitioning`)
        _messagesToResend.forEach(message => _socket.send(message))
      }

      if (previousSocket) {
        previousSocket.close()
        debug(`closed previous connection to ${previousSocket._master.name} at ${previousSocket._master.endpoint}`)
      } else {
        connection.emit('connect')
      }
    }, 500)

    newSocket.once('connect', () => onSocketConnected())
    return connection
  }
  /**
   * if present, closes the pub socket
   * @return {object} the publishConnection instance
   */
  function disconnect () {
    _connectingMaster = null
    if (_socket) {
      _socket.close()
      _socket = null
      debug('disconnected')
      connection.emit('disconnect')
    }
    return connection
  }
  /**
   * takes a list of strings|buffers to publish as message's frames
   * in the channel passed as first argument;
   * decorates each message with a uid
   * @param  {string} channel
   * @param  {[string|buffer]} args
   */
  function publish (channel, ...args) {
    _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args)
  }

  return Object.defineProperties(connection, {
    connected: {get: () => !!_socket},
    master: {get: () => _socket && {..._socket._master}},
    connect: {value: connect},
    disconnect: {value: disconnect},
    publish: {value: publish}
  })
}
305253
def get_object(self):
        
        obj = super(PublishView, self).get_object()

        if not obj or not hasattr(obj, 'publish'):
            raise http.Http404

        return obj
1211551
protected IMessagePublication addAsynchronousPublication(MessagePublication publication) {
        try {
            pendingMessages.put(publication);
            return publication.markScheduled();
        } catch (InterruptedException e) {
            handlePublicationError(new InternalPublicationError(e, "Error while adding an asynchronous message publication", publication));
            return publication;
        }
    }
784983
def only_published(cls, at=None):
		
		
		if isinstance(at, timedelta):
			at = utcnow() + at
		else:
			at = at or utcnow()
		
		pub, ret = cls.published, cls.retracted
		
		publication = (-pub) | (pub == None) | (pub <= at)
		retraction = (-ret) | (ret == None) | (ret > at)
		
		return publication & retraction
34875
def publish(self, subject, msg, reply=None):
        
        if msg is None:
            msg = ''

        if reply is None:
            command = 'PUB %s %d' % (subject, len(msg))
        else:
            command = 'PUB %s %s %d' % (subject, reply, len(msg))

        self._send(command)
        self._send(msg)
225967
def publish(self, *args, **kwargs):
        '''
        
        '''
        if self.channel.confirm._enabled:
            self._msg_id += 1
        super(RabbitBasicClass, self).publish(*args, **kwargs)
        return self._msg_id
970908
async def publish(self, channel, event, data=None):
        
        msg = {'event': event, 'channel': channel}
        if data:
            msg['data'] = data
        try:
            await self.pubsub.publish(self.prefixed(channel), msg)
        except ConnectionRefusedError:
            self.connection_error = True
            self.logger.critical(
                '%s cannot publish on "%s" channel - connection error',
                self,
                channel
            )
        else:
            self.connection_ok()
106936
def dump(self):
        '''
        
        '''
        return self.publ.public_bytes(
            encoding=c_ser.Encoding.DER,
            format=c_ser.PublicFormat.SubjectPublicKeyInfo)
627701
@Deprecated
    // TODO: Remove in Smack 4.5.
    public static PubSubManager getInstance(XMPPConnection connection, BareJid pubSubService) {
        return getInstanceFor(connection, pubSubService);
    }
982152
def get_pub_address(name, timeout=10, nameserver="localhost"):
    

    # Socket to talk to server
    socket = get_context().socket(REQ)
    try:
        socket.setsockopt(LINGER, timeout * 1000)
        socket.connect("tcp://" + nameserver + ":" + str(PORT))
        logger.debug('Connecting to %s',
                     "tcp://" + nameserver + ":" + str(PORT))
        poller = Poller()
        poller.register(socket, POLLIN)

        message = Message("/oper/ns", "request", {"service": name})
        socket.send_string(six.text_type(message))

        # Get the reply.
        sock = poller.poll(timeout=timeout * 1000)
        if sock:
            if sock[0][0] == socket:
                message = Message.decode(socket.recv_string(NOBLOCK))
                return message.data
        else:
            raise TimeoutError("Didn't get an address after %d seconds."
                               % timeout)
    finally:
        socket.close()
399112
def publisher(self):
        
        # Return information from FULL view, fall back to other views
        full = chained_get(self._head, ['source', 'publisher', 'publishername'])
        if full is None:
            return self._json['coredata'].get('dc:publisher')
        else:
            return full
1229195
def create(self, publish):
        
        target_url = self.client.get_url('PUBLISH', 'POST', 'create')
        r = self.client.request('POST', target_url, json=publish._serialize())
        return self.create_from_result(r.json())
113207
def publish(self, payload, **kwargs):
        
        publish_kwargs = self.publish_kwargs.copy()

        # merge headers from when the publisher was instantiated
        # with any provided now; "extra" headers always win
        headers = publish_kwargs.pop('headers', {}).copy()
        headers.update(kwargs.pop('headers', {}))
        headers.update(kwargs.pop('extra_headers', {}))

        use_confirms = kwargs.pop('use_confirms', self.use_confirms)
        transport_options = kwargs.pop('transport_options',
                                       self.transport_options
                                       )
        transport_options['confirm_publish'] = use_confirms

        delivery_mode = kwargs.pop('delivery_mode', self.delivery_mode)
        mandatory = kwargs.pop('mandatory', self.mandatory)
        priority = kwargs.pop('priority', self.priority)
        expiration = kwargs.pop('expiration', self.expiration)
        serializer = kwargs.pop('serializer', self.serializer)
        compression = kwargs.pop('compression', self.compression)
        retry = kwargs.pop('retry', self.retry)
        retry_policy = kwargs.pop('retry_policy', self.retry_policy)

        declare = self.declare[:]
        declare.extend(kwargs.pop('declare', ()))

        publish_kwargs.update(kwargs)  # remaining publish-time kwargs win

        with get_producer(self.amqp_uri,
                          use_confirms,
                          self.ssl,
                          transport_options,
                          ) as producer:
            try:
                producer.publish(
                    payload,
                    headers=headers,
                    delivery_mode=delivery_mode,
                    mandatory=mandatory,
                    priority=priority,
                    expiration=expiration,
                    compression=compression,
                    declare=declare,
                    retry=retry,
                    retry_policy=retry_policy,
                    serializer=serializer,
                    **publish_kwargs
                )
            except ChannelError as exc:
                if "NO_ROUTE" in str(exc):
                    raise UndeliverableMessage()
                raise

            if mandatory:
                if not use_confirms:
                    warnings.warn(
                        "Mandatory delivery was requested, but "
                        "unroutable messages cannot be detected without "
                        "publish confirms enabled."
                    )
276037
def convert_broadcast_to(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    shape_list = convert_string_to_list(attrs["shape"])

    initializer = kwargs["initializer"]
    output_shape_np = np.array(shape_list, dtype='int64')
    data_type = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[output_shape_np.dtype]
    dims = np.shape(output_shape_np)

    output_shape_name = "expand_attr_tensor" + str(kwargs["idx"])
    tensor_node = onnx.helper.make_tensor_value_info(output_shape_name, data_type, dims)

    initializer.append(
        onnx.helper.make_tensor(
            name=output_shape_name,
            data_type=data_type,
            dims=dims,
            vals=shape_list,
            raw=False,
        )
    )

    input_nodes.append(output_shape_name)
    expand_node = onnx.helper.make_node(
        "Expand",
        input_nodes,
        [name],
        name=name
    )

    return [tensor_node, expand_node]
1063267
def rpc(message_name, data=nil, opts={})
      message_name = validated_message_name(message_name)
      publisher.rpc(message_name, data, opts)
    end
849417
public <T> Stream<T> stream( Publisher pub, int batchSize ) {
        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator(pub, batchSize), Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
    }