parameters: (self, fil=None, sort=None)
return_statement: return res
docstring: list directory contents, possibly filter by the given fil func
              and possibly sorted.
docstring_summary: list directory contents, possibly filter by the given fil func
              and possibly sorted.
docstring_tokens: list directory contents possibly filter by the given fil func and possibly sorted .
function: def listdir(self, fil=None, sort=None):
          """ list directory contents, possibly filter by the given fil func
              and possibly sorted.
          """
          if fil is None and sort is None:
              names = py.error.checked_call(os.listdir, self.strpath)
              return map_as_list(self._fastjoin, names)
          if isinstance(fil, py.builtin._basestring):
              if not self._patternchars.intersection(fil):
                  child = self._fastjoin(fil)
                  if exists(child.strpath):
                      return [child]
                  return []
              fil = common.FNMatcher(fil)
          names = py.error.checked_call(os.listdir, self.strpath)
          res = []
          for name in names:
              child = self._fastjoin(name)
              if fil is None or fil(child):
                  res.append(child)
          self._sortlist(res, sort)
          return res
function_tokens: def listdir ( self , fil = None , sort = None ) : if fil is None and sort is None : names = py . error . checked_call ( os . listdir , self . strpath ) return map_as_list ( self . _fastjoin , names ) if isinstance ( fil , py . builtin . _basestring ) : if not self . _patternchars . intersection ( fil ) : child = self . _fastjoin ( fil ) if exists ( child . strpath ) : return [ child ] return [ ] fil = common . FNMatcher ( fil ) names = py . error . checked_call ( os . listdir , self . strpath ) res = [ ] for name in names : child = self . _fastjoin ( name ) if fil is None or fil ( child ) : res . append ( child ) self . _sortlist ( res , sort ) return res