orb.misc.auto_obj module

class orb.misc.auto_obj.AutoObj(dict1)

Bases: object

Recursively convert given data to objects.

>>> AutoObj(dict(a='1')).a
'1'
get(key, default=None)
toJSON()
todict()
orb.misc.auto_obj.dict2obj(dict1)

Recursively convert any data type to float or int if and when appropriate to do so. Also convert the an object.

>>> dict2obj(dict(a='1')).a
1
orb.misc.auto_obj.sort_dict(item: dict)
orb.misc.auto_obj.string_to_num(data)

Convert the given data to float or int: whichever one fits best.

>>> string_to_num('1')
1
>>> string_to_num('1.0')
1.0
orb.misc.auto_obj.to_num(data)

Recursively convert any data type to float or int if and when appropriate to do so.

>>> to_num(dict(a='1', b=dict(c='1.0')))['b']['c']
1.0
orb.misc.auto_obj.todict(obj, classkey=None)

Recursively convert an object to a dict. >>> obj = AutoObj(dict(a=’1’)) >>> todict(obj)[‘a’] ‘1’