MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / StreamReaderWriter

Class StreamReaderWriter

tools/python-3.11.9-amd64/Lib/codecs.py:674–760  ·  view source on GitHub ↗

StreamReaderWriter instances allow wrapping streams which work in both read and write modes. The design is such that one can use the factory functions returned by the codec.lookup() function to construct the instance.

Source from the content-addressed store, hash-verified

672###
673
674class StreamReaderWriter:
675
676 """ StreamReaderWriter instances allow wrapping streams which
677 work in both read and write modes.
678
679 The design is such that one can use the factory functions
680 returned by the codec.lookup() function to construct the
681 instance.
682
683 """
684 # Optional attributes set by the file wrappers below
685 encoding = 'unknown'
686
687 def __init__(self, stream, Reader, Writer, errors='strict'):
688
689 """ Creates a StreamReaderWriter instance.
690
691 stream must be a Stream-like object.
692
693 Reader, Writer must be factory functions or classes
694 providing the StreamReader, StreamWriter interface resp.
695
696 Error handling is done in the same way as defined for the
697 StreamWriter/Readers.
698
699 """
700 self.stream = stream
701 self.reader = Reader(stream, errors)
702 self.writer = Writer(stream, errors)
703 self.errors = errors
704
705 def read(self, size=-1):
706
707 return self.reader.read(size)
708
709 def readline(self, size=None):
710
711 return self.reader.readline(size)
712
713 def readlines(self, sizehint=None):
714
715 return self.reader.readlines(sizehint)
716
717 def __next__(self):
718
719 """ Return the next decoded line from the input stream."""
720 return next(self.reader)
721
722 def __iter__(self):
723 return self
724
725 def write(self, data):
726
727 return self.writer.write(data)
728
729 def writelines(self, list):
730
731 return self.writer.writelines(list)

Callers 1

openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected