Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
encodings.idna.IncrementalEncoder Class Reference
Inheritance diagram for encodings.idna.IncrementalEncoder:
Inheritance graph
[legend]
Collaboration diagram for encodings.idna.IncrementalEncoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def encode
def reset
def getstate
def setstate

Public Attributes

 buffer
 errors
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _buffer_encode

Detailed Description

Definition at line 196 of file idna.py.


Member Function Documentation

def encodings.idna.IncrementalEncoder._buffer_encode (   self,
  input,
  errors,
  final 
) [private]

Reimplemented from codecs.BufferedIncrementalEncoder.

Definition at line 197 of file idna.py.

00197 
00198     def _buffer_encode(self, input, errors, final):
00199         if errors != 'strict':
00200             # IDNA is quite clear that implementations must be strict
00201             raise UnicodeError("unsupported error handling "+errors)
00202 
00203         if not input:
00204             return (b'', 0)
00205 
00206         labels = dots.split(input)
00207         trailing_dot = b''
00208         if labels:
00209             if not labels[-1]:
00210                 trailing_dot = b'.'
00211                 del labels[-1]
00212             elif not final:
00213                 # Keep potentially unfinished label until the next call
00214                 del labels[-1]
00215                 if labels:
00216                     trailing_dot = b'.'
00217 
00218         result = bytearray()
00219         size = 0
00220         for label in labels:
00221             if size:
00222                 # Join with U+002E
00223                 result.extend(b'.')
00224                 size += 1
00225             result.extend(ToASCII(label))
00226             size += len(label)
00227 
00228         result += trailing_dot
00229         size += len(trailing_dot)
00230         return (bytes(result), size)

Here is the call graph for this function:

def codecs.BufferedIncrementalEncoder.encode (   self,
  input,
  final = False 
) [inherited]
Encodes input and returns the resulting object.

Reimplemented from codecs.IncrementalEncoder.

Definition at line 214 of file codecs.py.

00214 
00215     def encode(self, input, final=False):
00216         # encode input (taking the buffer into account)
00217         data = self.buffer + input
00218         (result, consumed) = self._buffer_encode(data, self.errors, final)
00219         # keep unencoded input until the next call
00220         self.buffer = data[consumed:]
00221         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def codecs.BufferedIncrementalEncoder.getstate (   self) [inherited]
Return the current state of the encoder.

Reimplemented from codecs.IncrementalEncoder.

Definition at line 226 of file codecs.py.

00226 
00227     def getstate(self):
00228         return self.buffer or 0

def codecs.BufferedIncrementalEncoder.reset (   self) [inherited]
Resets the encoder to the initial state.

Reimplemented from codecs.IncrementalEncoder.

Definition at line 222 of file codecs.py.

00222 
00223     def reset(self):
00224         IncrementalEncoder.reset(self)
00225         self.buffer = ""

Here is the caller graph for this function:

def codecs.BufferedIncrementalEncoder.setstate (   self,
  state 
) [inherited]
Set the current state of the encoder. state must have been
returned by getstate().

Reimplemented from codecs.IncrementalEncoder.

Definition at line 229 of file codecs.py.

00229 
00230     def setstate(self, state):
00231         self.buffer = state or ""


Member Data Documentation

Reimplemented from codecs.IncrementalEncoder.

Definition at line 207 of file codecs.py.

Creates an IncrementalEncoder instance.

The IncrementalEncoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.

Reimplemented in encodings.bz2_codec.IncrementalEncoder, encodings.zlib_codec.IncrementalEncoder, encodings.base64_codec.IncrementalEncoder, and encodings.hex_codec.IncrementalEncoder.

Definition at line 172 of file codecs.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


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