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

Source Code for Module pyamf.adapters.util

 1  # Copyright (c) 2007-2009 The PyAMF Project. 
 2  # See LICENSE.txt for details. 
 3   
 4  """ 
 5  Useful helpers for adapters. 
 6   
 7  @since: 0.4 
 8  """ 
 9   
10  import __builtin__ 
11   
12  if not hasattr(__builtin__, 'set'): 
13      from sets import Set as set 
14   
15   
16 -def to_list(obj, encoder):
17 """ 18 Converts an arbitrary object C{obj} to a list. 19 20 @rtype: L{list} 21 """ 22 return list(obj)
23 24
25 -def to_dict(obj, encoder):
26 """ 27 Converts an arbitrary object C{obj} to a dict. 28 29 @rtype: L{dict} 30 """ 31 return dict(obj)
32 33
34 -def to_set(obj, encoder):
35 """ 36 Converts an arbitrary object C{obj} to a set. 37 38 @rtype: L{set} 39 """ 40 return set(obj)
41 42
43 -def to_tuple(x, encoder):
44 """ 45 Converts an arbitrary object C{obj} to a tuple. 46 47 @rtype: L{tuple} 48 """ 49 return tuple(x)
50
51 -def to_string(x, encoder):
52 """ 53 Converts an arbitrary object C{obj} to a string. 54 55 @rtype: L{tuple} 56 @since: 0.5 57 """ 58 return str(x)
59