[augeas-devel] Expanded path expressions

David Lutterkort lutter at redhat.com
Mon Dec 22 23:21:10 UTC 2008


This series of patches enhances the path expressions that Augeas
understands. The main changes are that

(1) you can now go backwards from last(), e.g. to get the penultimate alias
    node:
    /files/etc/hosts/1/alias[last() - 1]
(2) you can find nodes with a given value
    /files/etc/hosts/*/*[value() = '127.0.0.1']
(3) you can find nodes that have children with a fixed value, e.g.
    /files/etc/hosts/*[ipaddr = '127.0.0.1']
(4) you can combine several predicates to find nodes that match all of them:
    /files/etc/pam.d/*/*[module = 'system-auth'][type = 'account']/control

More examples can be found in tests/xpath.tests

I am posting these patches mostly for comment. I haven't decided whether to
include this in the next release, or to enhance it more before
releasing. There's quite a few thigns I would like to still add. The most
important ones are:

(a) filter based on nodes that aren't children, e.g.
    /files/etc/hosts/canonical[ ../ipaddr = '127.0.0.1' ]
    /files/etc/ssh/sshd_config/Match/Settings[ ../Condition/User = 'sarko' ]
(b) search over whole subtrees with '//', e.g.
    /augeas/files//error
(c) more flexible string operations besides checking for equality, e.g.
    /files/etc/hosts/*[ starts-with(ipaddr, '127.0') ]
    /files/etc/ssh/sshd_config/Match/Settings[ contains(../Condition/User, 'sarko') ]

David




More information about the augeas-devel mailing list