Package pyamf :: Module amf0 :: Class Encoder
[hide private]
[frames] | no frames]

Class Encoder

source code


Encodes an AMF0 stream.

Nested Classes [hide private]
type or types.ClassType context_class
Holds the class that will create context objects for the implementing Encoder.
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
writeType(self, t)
Writes the type to the stream.
source code
 
writeUndefined(self, data)
Writes the undefined data type to the stream.
source code
 
writeClass(self, *args, **kwargs)
Classes cannot be serialised.
source code
 
writeFunc(self, *args, **kwargs)
Functions cannot be serialised.
source code
 
writeUnsupported(self, data)
Writes unsupported data type to the stream.
source code
callable or None.
_writeElementFunc(self, data)
Gets a function based on the type of data.
source code
 
writeElement(self, data)
Writes the data.
source code
 
writeNull(self, n)
Write null type to data stream.
source code
 
writeArray(self, a)
Write array to the stream.
source code
 
writeNumber(self, n)
Write number to the data stream.
source code
 
writeBoolean(self, b)
Write boolean to the data stream.
source code
 
writeString(self, s, writeType=True)
Write string to the data stream.
source code
 
writeReference(self, o)
Write reference to the data stream.
source code
 
_writeDict(self, o)
Write dict to the data stream.
source code
 
writeMixedArray(self, o)
Write mixed array to the data stream.
source code
 
_writeEndObject(self) source code
 
writeObject(self, o)
Write object to the stream.
source code
 
writeDate(self, d)
Writes a date to the data stream.
source code
 
writeXML(self, e)
Write XML to the data stream.
source code
 
writeAMF3(self, data)
Writes an element to the datastream in AMF3 format.
source code

Inherited from BaseEncoder (private): _getWriteElementFunc

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
list type_map = [((<type 'builtin_function_or_method'>, <type 'buil...
A list of types -> functions.
Instance Variables [hide private]
bool use_amf3
A flag to determine whether this encoder knows about AMF3.

Inherited from BaseEncoder: context, stream, strict, timezone_offset

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

writeType(self, t)

source code 

Writes the type to the stream.

Parameters:
  • t (str) - ActionScript type.
Raises:

writeUndefined(self, data)

source code 

Writes the undefined data type to the stream.

Parameters:
  • data (undefined data) - The undefined data to be encoded to the AMF0 data stream.

writeFunc(self, *args, **kwargs)

source code 

Functions cannot be serialised.

Raises:
Overrides: BaseEncoder.writeFunc

writeUnsupported(self, data)

source code 

Writes unsupported data type to the stream.

Parameters:
  • data (unsupported data) - The unsupported data to be encoded to the AMF0 data stream.

_writeElementFunc(self, data)

source code 

Gets a function based on the type of data.

Parameters:
  • data - Python data.
Returns: callable or None.
The function used to encode data to the stream.
Overrides: BaseEncoder._writeElementFunc

writeElement(self, data)

source code 

Writes the data.

Parameters:
  • data (mixed) - The data to be encoded to the AMF0 data stream.
Raises:
Overrides: BaseEncoder.writeElement

writeNull(self, n)

source code 

Write null type to data stream.

Parameters:
  • n (None) - Is ignored.

writeArray(self, a)

source code 

Write array to the stream.

Parameters:

writeNumber(self, n)

source code 

Write number to the data stream.

Parameters:

writeBoolean(self, b)

source code 

Write boolean to the data stream.

Parameters:

writeString(self, s, writeType=True)

source code 

Write string to the data stream.

Parameters:
  • s (BufferedByteStream) - The string data to be encoded to the AMF0 data stream.
  • writeType (bool) - Write data type.

writeReference(self, o)

source code 

Write reference to the data stream.

Parameters:

_writeDict(self, o)

source code 

Write dict to the data stream.

Parameters:
  • o (iterable) - The dict data to be encoded to the AMF0 data stream.

writeMixedArray(self, o)

source code 

Write mixed array to the data stream.

Parameters:

writeObject(self, o)

source code 

Write object to the stream.

Parameters:

writeDate(self, d)

source code 

Writes a date to the data stream.

Parameters:
  • d (Instance of datetime.datetime) - The date to be encoded to the AMF0 data stream.

writeXML(self, e)

source code 

Write XML to the data stream.

Parameters:

writeAMF3(self, data)

source code 

Writes an element to the datastream in AMF3 format.

Parameters:
  • data (mixed) - The data to be encoded to the AMF0 data stream.

Class Variable Details [hide private]

type_map

A list of types -> functions. The types is a list of possible instances or functions to call (that return a bool) to determine the correct function to call to encode the data.
Type:
list
Value:
[((<type 'builtin_function_or_method'>,
   <type 'builtin_function_or_method'>,
   <type 'function'>,
   <type 'generator'>,
   <type 'module'>,
   <type 'function'>,
   <type 'instancemethod'>),
  'writeFunc'),
...