On Thu, Apr 8, 2010 at 3:06 AM, Ville M. Vainio <vivai...@gmail.com> wrote:
> On Thu, Apr 8, 2010 at 10:53 AM, Edward K. Ream <edream...@gmail.com> wrote:
>
>> I agree.  I was thinking that the user would build python_cmpltns.py.
>> We probably don't want that, but probably do want to cache data for
>> standard modules somewhere.
>
> I may sound like a broken record, but this is all taken care of by
> codewise / ctags scheme...

Early this morning I took a look at codewise. A few notes before I forget.

1. I got codewise using

bzr branch lp:codewise
python setup.py install

as mentioned at
http://www.mail-archive.com/leo-editor@googlegroups.com/msg10145.html

I got this url googling 'python codewise'.  That is, I had forgotten
all about last year's post.  From the url I see that this was a post
on leo-editor.  Searching leo-editor for codewise yields several
pages, including
http://groups.google.com/group/leo-editor/browse_thread/thread/79ad988e3fe14dfe/fedbeed65f7d1bb6?lnk=gst&q=codewise#fedbeed65f7d1bb6

2. The actual code is at https://code.launchpad.net/~villemvainio/codewise/trunk

Ville, could you give me access to this branch?  I have some changes I
would like to make.

3.  I now have codewise.py working with a modified version of the
codewisecompleter plugin.  This new code works with both python 3.1
and (presumably, not tested) python 2.x.

Changes I made:

A. Added parens to print statements for Python 3.x compatibility.

B. Added isPython3 constant, just like in leoGlobals.leo.  This is
used in several places as follows:

    if not isPython3:
            l = unicode(l, 'utf8', 'replace')

C. Return the computed list in cmd_members and cmd_functions.  This
allows codewisecompleter.py to avoid popen as follows. Change::

    hits = (z.split(None,1) for z in os.popen('codewise m %s' %
klasses[0]) if z.strip())

to::

    aList = codewise.cmd_members([klasses[0]])
    hits = (z.split(None,1) for z in aList if z.strip())

Also change:

    hits = (z.split(None,1) for z in os.popen('codewise f %s' %
prefix) if z.strip())

to::

    aList = codewise.cmd_functions([prefix])
    hits = (z.split(None,1) for z in aList if z.strip())

I made these changes so that the new statement 'import codewise' will
use Python's module resolution logic to get the proper version of
codewise for the Python interp in use.  And btw, popen is deprecated
since Python 2.6 :-)

D.  I protected the results return by  get_attr_target_python .  For example:

    m = get_attr_target_python(head)
    if m:
        obj = m.group(1)
        prefix = m.group(3)
        klasses = guess_class(c,p, obj)
    else:
        klasses = []

That's about it.  Oh yes.  One more thing.  The docstring for
codewisecompleter.py is the same as ctagscompleter.py.  This was very
confusing.  It should, I think, be based on the docstring in
codewise.py.  Once I started reading the correct docstring, I could
call codewise.py from the command line to set up ~/.codewise.db.  Once
that happened, code completion started to work :-)  I also started to
understand what in blazes was going on :-)

Edward

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

Reply via email to