[IPython-dev] ipipe news

Fernando Perez Fernando.Perez at colorado.edu
Thu Mar 2 18:57:08 EST 2006


Walter Dörwald wrote:

>>I'd like to ask though, if I'm doing something wrong in trying to use 
>>it.  I simply read the 'ipipe?' docstring and typed the first example:
>>
>>In [1]: from ipipe import *
>>
>>In [2]: iwalk | ifilter("name.endswith('.py')") | isort("size")
>>
>>
>>It all seems to work (I saw a lot of network traffic, consistent with a 
>>directory traversal on our NFS-mounted filesystem).  But the curses 
>>browser doesn't show anything at all when it opens, and no error is 
>>printed.  It lists '0 objects' in the status line.  Am I missing 
>>something here?
> 
> 
> isort() of course first has to fetch the complete input, before it can 
> sort the objects, so this might take longer. Dropping the sort 
> expression should speed up the initial display.
> 
> But as you get '0 objects' this probably means that you don't have any 
> Python source files in your current directory.

No, that's not the case:

In [4]: ls *.py
argv.py*  cf.py   env.py*    exit2.py*     sciweave.py  vars.py
avg.py*   die.py  error.py*  exit.py*      scopes.py*   xplot.py*
bar.py    div.py  err.py     ramptest.py*  strings.py

And in addition, I thought it was recursive, so I thought it would work even 
if the parent directory had no .py files (as long as subdirs had them).

> What happens if you do a simple "iwalk"?

That works fine.  But

iwalk | ifilter("name.endswith('.py')")

gives an empty browser, and

iwalk | isort("size")

produces a lovely traceback (here's just the end of it, let me know if you 
want a full one in verbose mode, I'll attach it).

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
_dodisplay(self, scr)
    1854             self.levels = []
    1855             # enter the first level
-> 1856             self.enter(self.input, xiter(self.input, "default"), 
*self.attrs)
    1857
    1858             self._calcheaderlines(None)

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
enter(self, item, mode, *attrs)
    1799                     item,
    1800                     iterator,
-> 1801                     self.scrsizey-1-self._headerlines-2,
    1802                     *attrs
    1803                 )

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
__init__(self, browser, input, iterator, mainsizey, *attrs)
    1399             self.colwidths = {} # Maps attribute names to column widths
    1400
-> 1401             self.fetch(mainsizey)
    1402             self.calcdisplayattrs()
    1403             # formatted attributes for the items on screen

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
fetch(self, count)
    1414                 except StopIteration:
    1415                     self.exhausted = True
-> 1416                     break
    1417                 else:
    1418                     have += 1

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
__xiter__(self, mode)
     988                 xiter(self.input, mode),
     989                 key=key,
--> 990                 reverse=self.reverse
     991             )
     992         for item in items:

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
sorted(iterator, key, reverse)
      56         items = list(iterator)
      57         if key is not None:
---> 58             items.sort(lambda i1, i2: cmp(key(i1), key(i2)))
      59         else:
      60             items.sort()

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
<lambda>(i1, i2)
      56         items = list(iterator)
      57         if key is not None:
---> 58             items.sort(lambda i1, i2: cmp(key(i1), key(i2)))
      59         else:
      60             items.sort()

/home/fperez/usr/lib/python2.3/site-packages/IPython/Extensions/ipipe.py in 
key(item)
     984         else:
     985             def key(item):
--> 986                 return eval(self.key, globals(), _AttrNamespace(item))
     987             items = sorted(
     988                 xiter(self.input, mode),

TypeError: eval() argument 3 must be dict, not _AttrNamespace


Cheers,

f




More information about the IPython-dev mailing list