|
Orbits
1
|
Public Member Functions | |
| def | __init__ |
| def | read |
| def | readline |
| def | readlines |
| def | next |
| def | __iter__ |
| def | write |
| def | writelines |
| def | reset |
| def | __getattr__ |
| def | __enter__ |
| def | __exit__ |
Public Attributes | |
| stream | |
| encode | |
| decode | |
| reader | |
| writer | |
| errors | |
Static Public Attributes | |
| string | data_encoding = 'unknown' |
| string | file_encoding = 'unknown' |
StreamRecoder instances provide a frontend - backend
view of encoding data.
They use the complete set of APIs returned by the
codecs.lookup() function to implement their task.
Data written to the stream is first decoded into an
intermediate format (which is dependent on the given codec
combination) and then written to the stream using an instance
of the provided Writer class.
In the other direction, data is read from the stream using a
Reader instance and then return encoded data to the caller. | def codecs.StreamRecoder.__init__ | ( | self, | |
| stream, | |||
| encode, | |||
| decode, | |||
| Reader, | |||
| Writer, | |||
errors = 'strict' |
|||
| ) |
Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
input to .read() and output of .write()) while
Reader and Writer work on the backend (reading and
writing to the stream).
You can use these objects to do transparent direct
recodings from e.g. latin-1 to utf-8 and back.
stream must be a file-like object.
encode, decode must adhere to the Codec interface, Reader,
Writer must be factory functions or classes providing the
StreamReader, StreamWriter interface resp.
encode and decode are needed for the frontend translation,
Reader and Writer for the backend translation. Unicode is
used as intermediate encoding.
Error handling is done in the same way as defined for the
StreamWriter/Readers.
| def codecs.StreamRecoder.__enter__ | ( | self | ) |
| def codecs.StreamRecoder.__exit__ | ( | self, | |
| type, | |||
| value, | |||
| tb | |||
| ) |
| def codecs.StreamRecoder.__getattr__ | ( | self, | |
| name, | |||
getattr = getattr |
|||
| ) |
Inherit all other methods from the underlying stream.
| def codecs.StreamRecoder.__iter__ | ( | self | ) |
| def codecs.StreamRecoder.next | ( | self | ) |
Return the next decoded line from the input stream.
| def codecs.StreamRecoder.read | ( | self, | |
size = -1 |
|||
| ) |
| def codecs.StreamRecoder.readline | ( | self, | |
size = None |
|||
| ) |
| def codecs.StreamRecoder.readlines | ( | self, | |
sizehint = None |
|||
| ) |
| def codecs.StreamRecoder.reset | ( | self | ) |
| def codecs.StreamRecoder.write | ( | self, | |
| data | |||
| ) |
| def codecs.StreamRecoder.writelines | ( | self, | |
| list | |||
| ) |
|
static |
| codecs.StreamRecoder.decode |
| codecs.StreamRecoder.encode |
| codecs.StreamRecoder.errors |
|
static |
| codecs.StreamRecoder.reader |
| codecs.StreamRecoder.stream |
| codecs.StreamRecoder.writer |
1.8.3.1
Copyright 2014 Google Inc. All rights reserved.