Package pyamf :: Package util
[hide private]
[frames] | no frames]

Package util

source code

AMF Utilities.


Since: 0.1.0

Submodules [hide private]

Classes [hide private]
  IndexedCollection
  IndexedMap
Like IndexedCollection, but also maps to another object.
  StringIOProxy
  DataTypeMixIn
Functions [hide private]
 
find_xml_lib()
Run through a predefined order looking through the various ElementTree implementations so that any type can be encoded but PyAMF will return elements as the first implementation found.
source code
str
hexdump(data)
Get hexadecimal representation of StringIO data.
source code
str
get_timestamp(d)
Returns a UTC timestamp for a datetime.datetime object.
source code
datetime.datetime
get_datetime(secs)
Return a UTC date from a timestamp.
source code
 
make_classic_instance(klass)
Create an instance of a classic class (not inherited from ``object``) without calling __init__().
source code
 
get_mro(C)
Compute the class precedence list (mro).
source code
 
get_attrs(obj)
Gets a dict of the attrs of an object in a predefined resolution order
source code
 
set_attrs(obj, attrs)
A generic function which applies a collection of attributes attrs to object obj
source code
 
get_class_alias(klass) source code
 
is_ET_element(obj)
Determines if the supplied obj param is a valid ElementTree element.
source code
 
is_float_broken()
Older versions of python (<=2.5) and the Windows platform are renowned for mixing up 'special' floats.
source code
 
read_double_workaround(self) source code
 
write_double_workaround(self, d) source code
 
x(self, d)
Writes an 8 byte float to the stream.
source code
Variables [hide private]
  xml_types = None
  nan = nan
  pos_inf = inf
  neg_inf = -inf
  negative_timestamp_broken = False

Imports: struct, calendar, datetime, types, pyamf, StringIO, ET, fpconst, BufferedByteStream, imports


Function Details [hide private]

find_xml_lib()

source code 

Run through a predefined order looking through the various ElementTree implementations so that any type can be encoded but PyAMF will return elements as the first implementation found.

We work through the C implementations first - then the pure python versions. The downside to this is that a possible of three libraries will be loaded into memory that are not used but the libs are small (relatively) and the flexibility that this gives seems to outweigh the cost. Time will tell.

Since: 0.4

hexdump(data)

source code 

Get hexadecimal representation of StringIO data.

Parameters:
  • data ()
Returns: str
Hexadecimal string.

get_timestamp(d)

source code 

Returns a UTC timestamp for a datetime.datetime object.

Parameters:
  • d (datetime.datetime) - The date object.
Returns: str
UTC timestamp.

Note: Inspiration taken from the Intertwingly blog.

get_datetime(secs)

source code 

Return a UTC date from a timestamp.

Parameters:
  • secs (long) - Seconds since 1970.
Returns: datetime.datetime
UTC timestamp.

make_classic_instance(klass)

source code 

Create an instance of a classic class (not inherited from ``object``) without calling __init__().

Parameters:
  • klass (class) - The classic class to create an instance for.
Returns:
instance created

get_mro(C)

source code 

Compute the class precedence list (mro).

Raises:
  • TypeError - class type expected.

set_attrs(obj, attrs)

source code 

A generic function which applies a collection of attributes attrs to object obj

Parameters:
  • obj - An instance implementing the __setattr__ function
  • attrs (Usually a dict) - A collection implementing the iteritems function

is_float_broken()

source code 

Older versions of python (<=2.5) and the Windows platform are renowned for mixing up 'special' floats. This function determines whether this is the case.

Since: 0.4