Python API to find a node is leaf or container by passing its Xpath

Hi Conny,

Is there a Python API to find a node is leaf or container by passing its Xpath?.
For example : is_leaf(xpath of leaf node)

Regards,
Harish P (Altiostar)

Hi Harish P,

Thank you for creating a separate topic for this question to make it easier for others to find it.

Any special reason why you need it to be an “XPath”.
You can do for example something like this:

from confd import maapi, maagic

with maapi.single_read_trans('admin', 'system') as trans:
        root = maagic.get_root(trans)
        path = "/myprefix:mycontainer"
        node = maagic.get_node(root, '%s' % path)
        print("%s is a container: %s" %(path,isinstance(node,(maagic.Container,maagic.PresenceContainer))))

        path = "/myprefix:mycontainer/myleaf"
        node = confd.maagic.get_node(root, '%s' % path)
        print("%s is a leaf; %s" %(path,not isinstance(node,(maagic.Container,maagic.PresenceContainer,maagic.List,maagic.LeafList))))