On Sat, Dec 18, 2010 at 5:56 PM, Terry Brown <[email protected]> wrote:

> I'm unclear as to the preferred methods for finding (a) the path in effect at 
> the node, and (b) the path of the derived file of which the node is a part, 
> if any.  Perhaps Edward can fill in those details.

d = c.scanAllDirectives(p) will return all the directives in effect at
node p, or at c.p if p is not given.  The path is d.get('path'), with
suitable default if no @path is in effect.

Unless performance is important (it usually is not), this is the most
convenient way to get path information.

As you can see from the code of c.scanAllDirectives,
c.scanAtPathDirectives can be used in conjunction with
g.get_directives_dict_list to get the path more directly, but less
conveniently.  c.getNodePath is a convenience method that does this,
but Leo's core does not use it.

Once you know the path in effect at a node, you can concatenate the
path to the file name of the @<file> node, using
p.anyAtFileNodeName(), which returns None if p is not an @<file> node.

In short:

if p.isAnyAtFileNode():
    fn = p.anyAtFileNodeName()
    path = c.getNodePath(p)
    fn2 = g.os_path_join(path,fn)

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to