1from .core
import encode, decode, alabel, ulabel, IDNAError
4from typing
import Tuple, Optional
6_unicode_dots_re =
re.compile(
'[\u002e\u3002\uff0e\uff61]')
10 def encode(self, data: str, errors: str =
'strict') -> Tuple[bytes, int]:
11 if errors !=
'strict':
12 raise IDNAError(
'Unsupported error handling \"{}\"'.format(errors))
17 return encode(data),
len(data)
19 def decode(self, data: bytes, errors: str =
'strict') -> Tuple[str, int]:
20 if errors !=
'strict':
21 raise IDNAError(
'Unsupported error handling \"{}\"'.format(errors))
26 return decode(data),
len(data)
29 def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]:
30 if errors !=
'strict':
31 raise IDNAError(
'Unsupported error handling \"{}\"'.format(errors))
57 result_str =
'.'.join(result) + trailing_dot
58 size +=
len(trailing_dot)
59 return result_str, size
62 def _buffer_decode(self, data: str, errors: str, final: bool) -> Tuple[str, int]:
63 if errors !=
'strict':
64 raise IDNAError(
'Unsupported error handling \"{}\"'.format(errors))
89 result_str =
'.'.join(result) + trailing_dot
90 size +=
len(trailing_dot)
91 return (result_str, size)
106 encode=Codec().encode,
107 decode=Codec().decode,
108 incrementalencoder=IncrementalEncoder,
109 incrementaldecoder=IncrementalDecoder,
110 streamwriter=StreamWriter,
111 streamreader=StreamReader,
Tuple[str, int] _buffer_decode(self, str data, str errors, bool final)
Tuple[str, int] _buffer_encode(self, str data, str errors, bool final)
codecs.CodecInfo getregentry()