Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
IncrementalDecoder Class Reference
Inheritance diagram for IncrementalDecoder:
Collaboration diagram for IncrementalDecoder:

Public Member Functions

 __init__ (self, fallback_encoding, errors='replace')
 
 decode (self, input, final=False)
 

Data Fields

 encoding
 

Protected Attributes

 _fallback_encoding
 
 _errors
 
 _buffer
 
 _decoder
 

Detailed Description

“Push”-based decoder.

:param fallback_encoding:
    An :class:`Encoding` object or a label string.
    The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.

Definition at line 272 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  fallback_encoding,
  errors = 'replace' 
)

Definition at line 283 of file __init__.py.

283 def __init__(self, fallback_encoding, errors='replace'):
284 # Fail early if `encoding` is an invalid label.
285 self._fallback_encoding = _get_encoding(fallback_encoding)
286 self._errors = errors
287 self._buffer = b''
288 self._decoder = None
289 #: The actual :class:`Encoding` that is being used,
290 #: or :obj:`None` if that is not determined yet.
291 #: (Ie. if there is not enough input yet to determine
292 #: if there is a BOM.)
293 self.encoding = None # Not known yet.
294

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ decode()

decode (   self,
  input,
  final = False 
)
Decode one chunk of the input.

:param input: A byte string.
:param final:
    Indicate that no more input is available.
    Must be :obj:`True` if this is the last call.
:returns: An Unicode string.

Definition at line 295 of file __init__.py.

295 def decode(self, input, final=False):
296 """Decode one chunk of the input.
297
298 :param input: A byte string.
299 :param final:
300 Indicate that no more input is available.
301 Must be :obj:`True` if this is the last call.
302 :returns: An Unicode string.
303
304 """
305 decoder = self._decoder
306 if decoder is not None:
307 return decoder(input, final)
308
309 input = self._buffer + input
310 encoding, input = _detect_bom(input)
311 if encoding is None:
312 if len(input) < 3 and not final: # Not enough data yet.
313 self._buffer = input
314 return ''
315 else: # No BOM
316 encoding = self._fallback_encoding
317 decoder = encoding.codec_info.incrementaldecoder(self._errors).decode
318 self._decoder = decoder
319 self.encoding = encoding
320 return decoder(input, final)
321
322
for i

References Unpacker._buffer, Packer._buffer, Console._buffer(), Console._buffer, IncrementalDecoder._buffer, HTTPResponse._decoder, IncrementalDecoder._decoder, pip._vendor.webencodings._detect_bom(), IncrementalDecoder._errors, IncrementalDecoder._fallback_encoding, IndexContent.encoding, StreamWrapper.encoding(), ResultDict.encoding, Formatter.encoding, HtmlFormatter.encoding, FontManager.encoding, ImageFormatter.encoding, RawTokenFormatter.encoding, SvgFormatter.encoding, Lexer.encoding, Response.encoding, ConsoleOptions.encoding, Console.encoding(), IncrementalDecoder.encoding, and i.

Here is the call graph for this function:

Field Documentation

◆ _buffer

◆ _decoder

◆ _errors

_errors
protected

Definition at line 286 of file __init__.py.

Referenced by IncrementalDecoder.decode().

◆ _fallback_encoding

_fallback_encoding
protected

Definition at line 285 of file __init__.py.

Referenced by IncrementalDecoder.decode().

◆ encoding


The documentation for this class was generated from the following file: