Comment 11 for bug 1023236

Revision history for this message
Russell Sim (russell-sim) wrote : Re: [Bug 1023236] Re: py-find-imports can't handle multiline imports or comma separated imports

A simple example

try:
    import broken__
except:
    import os

But I have seen examples with if statements. I'll grab one when I get home.
On Jul 16, 2012 6:10 PM, "Andreas Roehler" <email address hidden>
wrote:

> Am 16.07.2012 04:34, schrieb Russell Sim:
> > Andreas Roehler <email address hidden> writes:
> >
> >> you are referring to compound statements, while py-end-of-statement
> >> deals with simple statement.
> >
> >> Rusell provided a solution for a special case, which is okay. However,
> >> seen from this point, it's probable, there might be more and other
> >> special cases: blank lines, comments , lists over multiple lines etc.
> >
> > We could perhaps copy the data out to a temporary buffer and use find
> > and replace to change the ; characters to newlines. That should make it
> > work for *most* other cases.
> >
> > I agree, probably one of the harder to parse forms will be.
> >
> > from os import (mknod, # import for later
> > open, # another interesting import
> > path) # import completed
> >
> >
> > So perhaps copy interesting lines to temporary buffer:
> > 1. Trim comments
> > 2. split the lines with a ;
> > 3. Delete the string \\\n from the buffer
> > 4. Parse with a simple regex for most of the imports.
> > 4. Parse with a regex that will work over multiple lines with ()
>
> should be implemented, basically inside py-end-of-statement
>
>
> >
> > The only thing that wont be handled will be conditional import, so I
> > guess it's best to leave them out for the time being.
>
> or rather go on herewith :)
>
> May you point me onto some example?
>
> thanks
>
> Andreas
>
>
> >
> > I'll make a branch see what I can put together....
> >
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1023236
>
> Title:
> py-find-imports can't handle multiline imports or comma separated
> imports
>
> Status in An Emacs mode for editing Python code:
> Fix Committed
>
> Bug description:
> Hi,
>
> I have been messing about with the autocomplete and in the process i
> found that the py-find-imports function didn't support, comma
> separated imports or mulitline imports. I have had a first run at
> implementing this functionality, if you have any feedback i will
> gladly adjust the patch.
>
> I apologize for not including tests, I have made a test import file,
> but adding the test was harder then i expected.
>
> Thank you,
> Russell
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/python-mode/+bug/1023236/+subscriptions
>