コード例 #1
0
ファイル: local.py プロジェクト: bigmlcom/pylibs
 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.FNMatcher(fil)
     res = []
     for name in py.error.checked_call(os.listdir, self.strpath):
         childurl = self.join(name)
         if fil is None or fil(childurl):
             res.append(childurl)
     self._sortlist(res, sort)
     return res
コード例 #2
0
 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.FNMatcher(fil)
     nameinfo_seq = self._listdir_nameinfo()
     if len(nameinfo_seq) == 1:
         name, info = nameinfo_seq[0]
         if name == self.basename and info.kind == "file":
             # if not self.check(dir=1):
             raise py.error.ENOTDIR(self)
     paths = [self.join(name) for (name, info) in nameinfo_seq]
     if fil:
         paths = [x for x in paths if fil(x)]
     self._sortlist(paths, sort)
     return paths
コード例 #3
0
    def listdir(self, fil=None, sort=None):
        """ return a sequence of Paths.

        listdir will return either a tuple or a list of paths
        depending on implementation choices.
        """
        if isinstance(fil, str):
            fil = common.FNMatcher(fil)
        # XXX unify argument naming with LocalPath.listdir
        def notsvn(path):
            return path.basename != ".svn"

        paths = []
        for localpath in self.localpath.listdir(notsvn):
            p = self.__class__(localpath, auth=self.auth)
            if notsvn(p) and (not fil or fil(p)):
                paths.append(p)
        self._sortlist(paths, sort)
        return paths
コード例 #4
0
 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