> On Aug 20, 2013, at 11:03 , Anthony Sorace <a...@9srv.net> wrote:
> 
> I'm in the middle of a medium-size python project. It would be
> really helpful if the plumber could do things like look up things
> in python's dot notation. Anyone have plumbing rules or helper
> functions they'd like to share for python work with acme and
> plumber on p9p?

I don’t think I ever shared what I came up with for this, and it’s come up on 
IRC a few times, so:

I wrote a script, apy [1], which takes arguments of a directory “wdir” and a 
python function “app.file.function", tries to find app/file in wdir or its 
parents, and plumbs the result.

Then this simple plumbing rule
        # Find python modules.
        type is text
        data matches '([0-9A-Za-z]*)\.([0-9A-Za-z]*)\.([0-9A-Za-z]*)'
        plumb start apy $wdir $0
will let me click on foo.bar.function names in my project and Acme will get me 
to the named function.

It’s very simplistic (in particular, it only bothers with functions and doesn’t 
really do anything about system modules unless you get lucky), but gets me 90% 
of what I wanted Acme to do for me when working with python. It’s particularly 
nice when looking at Django’s urls.py and treating it as an index.

I think I’m doing something silly with the newline trimming; if anyone wants to 
point out what I’m missing, I’d love to hear it.

Anthony

[1]     /n/sources/contrib/anothy/bin/unix/apy


Reply via email to