def listdir(self, fil=None, sort=None): |
""" list directory contents, possibly filter by the given fil func |
and possibly sorted. |
""" |
if isinstance(fil, str): |
fil = common.fnmatch(fil) |
nameinfo_seq = self._listdir_nameinfo() |
if len(nameinfo_seq) == 1: |
name, info = nameinfo_seq[0] |
if name == self.basename and info.kind == 'file': |
|
raise py.error.ENOTDIR(self) |
paths = self._make_path_tuple(nameinfo_seq) |
|
if fil or sort: |
paths = filter(fil, paths) |
paths = isinstance(paths, list) and paths or list(paths) |
if callable(sort): |
paths.sort(sort) |
elif sort: |
-> paths.sort() |
return paths |