Format: application/octet-stream
⬇ Download File (5.2 KB)
   1  import codecs
   2  import sys
   3  from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
   4  
   5  # For convenience:
   6  _Handler = Callable[[Exception], Tuple[Text, int]]
   7  _String = Union[bytes, str]
   8  _Errors = Union[str, Text, None]
   9  if sys.version_info < (3, 0):
  10      _Decodable = Union[bytes, Text]
  11      _Encodable = Union[bytes, Text]
  12  else:
  13      _Decodable = bytes
  14      _Encodable = str
  15  
  16  # This type is not exposed; it is defined in unicodeobject.c
  17  class _EncodingMap(object):
  18      def size(self) -> int: ...
  19  
  20  _MapT = Union[Dict[int, int], _EncodingMap]
  21  
  22  def register(__search_function: Callable[[str], Any]) -> None: ...
  23  def register_error(__errors: Union[str, Text], __handler: _Handler) -> None: ...
  24  def lookup(__encoding: Union[str, Text]) -> codecs.CodecInfo: ...
  25  def lookup_error(__name: Union[str, Text]) -> _Handler: ...
  26  def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
  27  def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
  28  def charmap_build(__map: Text) -> _MapT: ...
  29  def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
  30  def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  31  
  32  if sys.version_info < (3, 2):
  33      def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  34  
  35  def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ...
  36  def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
  37  def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
  38  def escape_encode(__data: bytes, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  39  def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
  40  def latin_1_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  41  def raw_unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
  42  def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  43  def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  44  def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
  45  def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  46  
  47  if sys.version_info < (3, 8):
  48      def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
  49      def unicode_internal_encode(__obj: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  50  
  51  def utf_16_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  52  def utf_16_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  53  def utf_16_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  54  def utf_16_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
  55  def utf_16_ex_decode(
  56      __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
  57  ) -> Tuple[Text, int, int]: ...
  58  def utf_16_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  59  def utf_16_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  60  def utf_32_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  61  def utf_32_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  62  def utf_32_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  63  def utf_32_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
  64  def utf_32_ex_decode(
  65      __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
  66  ) -> Tuple[Text, int, int]: ...
  67  def utf_32_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  68  def utf_32_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  69  def utf_7_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  70  def utf_7_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  71  def utf_8_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  72  def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  73  
  74  if sys.platform == "win32":
  75      def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  76      def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  77      if sys.version_info >= (3, 0):
  78          def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  79          def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  80      if sys.version_info >= (3, 6):
  81          def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
  82          def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
  83