Returns a raw text writer co-routine.

    Yields:
        DataEvent: serialization events to write out

        Receives :class:`amazon.ion.core.IonEvent` or ``None`` when the co-routine yields
        ``HAS_PENDING`` :class:`WriteEventType` events.
165435
def raw_writer(indent=None):
    

    is_whitespace_str = isinstance(indent, str) and re.search(r'\A\s*\Z', indent, re.M) is not None
    if not (indent is None or is_whitespace_str):
        raise ValueError('The indent parameter must either be None or a string containing only whitespace')

    indent_bytes = six.b(indent) if isinstance(indent, str) else indent

    return writer_trampoline(_raw_writer_coroutine(indent=indent_bytes))
206194
def write_events(self, state_change_identifier, events, log_time):
        
        events_data = [
            (None, state_change_identifier, log_time, self.serializer.serialize(event))
            for event in events
        ]
        return super().write_events(events_data)
857545
def Serialize(self, writer):
        
        super(Block, self).Serialize(writer)
        writer.WriteSerializableArray(self.Transactions)
1158293
def Serialize(self, writer):
        
        self.SerializeUnsigned(writer)
        writer.WriteByte(1)
        self.Script.Serialize(writer)
458943
async def stdout_writer():
    
    if sys.stdout.seekable():
        # it’s a file
        return sys.stdout.buffer.raw

    if os.isatty(sys.stdin.fileno()):
        # it’s a tty, use fd 0
        fd_to_use = 0
    else:
        fd_to_use = 1

    twrite, pwrite = await loop.connect_write_pipe(
        asyncio.streams.FlowControlMixin,
        os.fdopen(fd_to_use, "wb"),
    )

    swrite = asyncio.StreamWriter(
        twrite,
        pwrite,
        None,
        loop,
    )

    return swrite
102502
def _buffer(self, event: Message):
        
        if isinstance(event, BytesMessage):
            self._byte_buffer.write(event.data)
        elif isinstance(event, TextMessage):
            self._string_buffer.write(event.data)
496017
def write_event(self, event):
    
    self._lock.acquire()
    try:
      self._events_writer.WriteEvent(event)
      self._event_count += 1
      if self._always_flush:
        # We flush on every event within the integration test.
        self._events_writer.Flush()

      if self._event_count == self._check_this_often:
        # Every so often, we check whether the size of the file is too big.
        self._event_count = 0

        # Flush to get an accurate size check.
        self._events_writer.Flush()

        file_path = os.path.join(self._events_directory,
                                 self.get_current_file_name())
        if not tf.io.gfile.exists(file_path):
          # The events file does not exist. Perhaps the user had manually
          # deleted it after training began. Create a new one.
          self._events_writer.Close()
          self._events_writer = self._create_events_writer(
              self._events_directory)
        elif tf.io.gfile.stat(file_path).length > self._single_file_size_cap_bytes:
          # The current events file has gotten too big. Close the previous
          # events writer. Make a new one.
          self._events_writer.Close()
          self._events_writer = self._create_events_writer(
              self._events_directory)
    except IOError as err:
      logger.error(
          "Writing to %s failed: %s", self.get_current_file_name(), err)
    self._lock.release()
730636
def event_transition(self, event_cls, event_type, ion_type, value):
        """"""
        annotations = self.annotations or ()
        depth = self.depth
        whence = self.whence

        if ion_type is IonType.SYMBOL:
            if not annotations and depth == 0 and isinstance(value, _IVMToken):
                event = value.ivm_event()
                if event is None:
                    _illegal_character(None, self, 'Illegal IVM: %s.' % (value.text,))
                return Transition(event, whence)
            assert not isinstance(value, _IVMToken)

        return Transition(
            event_cls(event_type, ion_type, value, self.field_name, annotations, depth),
            whence
        )
647287
def write(self, title, data, output=None):
        '''
        
        '''
        if not isinstance(data, (dict, list, tuple)):
            data = {'raw-content': str(data)}
        output = output or self.__default_outputter

        if output != 'null':
            try:
                if isinstance(data, dict) and 'return' in data:
                    data = data['return']
                content = self._printout(data, output)
            except Exception:  # Fall-back to just raw YAML
                content = None
        else:
            content = None

        if content is None:
            data = json.loads(json.dumps(data))
            if isinstance(data, dict) and data.get('return'):
                data = data.get('return')
            content = yaml.safe_dump(data, default_flow_style=False, indent=4)

        self.__current_section.append({title: content})
294581
def write(self, text, flush=False, error=False, prompt=False):
        """"""
        if prompt:
            self.flush()
        if not is_string(text):
            # This test is useful to discriminate QStrings from decoded str
            text = to_text_string(text)
        self.__buffer.append(text)
        ts = time.time()
        if flush or prompt:
            self.flush(error=error, prompt=prompt)
        elif ts - self.__timestamp > 0.05:
            self.flush(error=error)
            self.__timestamp = ts
            # Timer to flush strings cached by last write() operation in series
            self.__flushtimer.start(50)
978622
void pumpEvents(InputStream eventStream) {
    try {
      Deserializer deserializer = new Deserializer(eventStream, refLoader);

      IEvent event = null;
      while ((event = deserializer.deserialize()) != null) {
        switch (event.getType()) {
          case APPEND_STDERR:
          case APPEND_STDOUT:
            // Ignore these two on activity heartbeats. GH-117
            break;
          default:
            lastActivity = System.currentTimeMillis();
            break;
        }

        try {
          switch (event.getType()) {
            case QUIT:
              eventBus.post(event);
              return;

            case IDLE:
              eventBus.post(new SlaveIdle(stdinWriter));
              break;

            case BOOTSTRAP:
              clientCharset = Charset.forName(((BootstrapEvent) event).getDefaultCharsetName());
              stdinWriter = new OutputStreamWriter(stdin, clientCharset);
              eventBus.post(event);
              break;

            case APPEND_STDERR:
            case APPEND_STDOUT:
              assert streamsBuffer.getFilePointer() == streamsBuffer.length();
              final long bufferStart = streamsBuffer.getFilePointer();
              IStreamEvent streamEvent = (IStreamEvent) event;
              streamEvent.copyTo(streamsBufferWrapper);
              final long bufferEnd = streamsBuffer.getFilePointer();

              event = new OnDiskStreamEvent(event.getType(), streamsBuffer, bufferStart, bufferEnd);
              eventBus.post(event);
              break;
              
            default:
              eventBus.post(event);
          }
        } catch (Throwable t) {
          warnStream.println("Event bus dispatch error: " + t.toString());
          t.printStackTrace(warnStream);
        }
      }
      lastActivity = null;
    } catch (Throwable e) {
      if (!stopping) {
        warnStream.println("Event stream error: " + e.toString());
        e.printStackTrace(warnStream);
      }
    }
  }
995773
def _writer(self):
        
        while not self.closed:
            try:
                sock, data = self._write_queue.get(timeout=0.1)
                self._write_queue.task_done()
                sock.send(data)
            except Empty:
                pass  # nothing to write after timeout
            except socket.error as err:
                if err.errno == errno.EBADF:
                    self._clean_dead_sessions()
30240
def write(self, data):
        
        if not isinstance(data, (bytes, bytearray, memoryview)):
            raise TypeError('data argument must be byte-ish (%r)',
                            type(data))

        if not self._state.is_writable or self._closing:
            raise self._invalid_state("write() called")

        if not data:
            return

        if not self._buffer:
            self._loop.add_writer(self._raw_fd, self._write_ready)

        self._buffer.extend(data)
1271002
def write_to(self, stream):
        
        if self.data is None:
            raise ValueError("Events must have at least the data field set to be written to XML.")

        event = ET.Element("event")
        if self.stanza is not None:
            event.set("stanza", self.stanza)
        event.set("unbroken", str(int(self.unbroken)))

        # if a time isn't set, let Splunk guess by not creating a <time> element
        if self.time is not None:
            ET.SubElement(event, "time").text = str(self.time)

        # add all other subelements to this Event, represented by (tag, text)
        subelements = [
            ("source", self.source),
            ("sourcetype", self.sourceType),
            ("index", self.index),
            ("host", self.host),
            ("data", self.data)
        ]
        for node, value in subelements:
            if value is not None:
                ET.SubElement(event, node).text = value

        if self.done:
            ET.SubElement(event, "done")

        stream.write(ET.tostring(event))
        stream.flush()
1132405
def writecooked(self, text):
        """"""
        # Ensure this is the only thread writing
        self.OQUEUELOCK.acquire()
        TelnetHandlerBase.writecooked(self, text)
        self.OQUEUELOCK.release()
638183
@Override
    public String getRawEvent(BulkWriteFailure event) throws IOException {
        return IOUtils.asString(event.getEntryContents());
    }
1194161
private XMLEventWriter createXmlEventWriter(FileWriter fileWriter)
            throws FactoryConfigurationError, XMLStreamException {
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        return new IndentingXMLEventWriter(factory
                .createXMLEventWriter(fileWriter));
    }