Helper function that supports XPath style selectors to traverse an object tree e.g.

inst = {'fixed_ip': {'floating_ips': [{'address': '1.2.3.4'}], 'address': '192.168.0.3'}, 'hostname': ''}

private_ips = get_from_path(inst, 'fixed_ip/address')
public_ips = get_from_path(inst, 'fixed_ip/floating_ips/address')

Avoids messy [.get() / if / for]* nested code
This commit is contained in:
Justin Santa Barbara
2011-02-23 22:50:33 +00:00
committed by Tarmac

Diff Content Not Available