diff --git a/IPython/Extensions/ipipe.py b/IPython/Extensions/ipipe.py index ec7711c..2345b6c 100644 --- a/IPython/Extensions/ipipe.py +++ b/IPython/Extensions/ipipe.py @@ -1180,11 +1180,22 @@ class ils(Table): >>> ils("/usr/local/lib/python2.4") >>> ils("~") """ - def __init__(self, base=os.curdir): + def __init__(self, base=os.curdir, dirs=True, files=True): self.base = os.path.expanduser(base) + self.dirs = dirs + self.files = files def __iter__(self): - return xiter(ifile(self.base)) + for child in ifile(self.base).listdir(): + if self.dirs: + if self.files: + yield child + else: + if child.isdir(): + yield child + elif self.files: + if not child.isdir(): + yield child def __xrepr__(self, mode): return ifile(self.base).__xrepr__(mode) diff --git a/doc/ChangeLog b/doc/ChangeLog index b56f4de..06d8e69 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2006-08-25 Walter Doerwald + + * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to + the constructor, this makes it possible to get a list of only directories + or only files. + 2006-08-12 Ville Vainio * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,