Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(19)  |  Call(18)  |  Derive(0)  |  Import(1)
Return a list of directory contents found under the source directory.

        def CollectDirectoryContents(srcDir, baseDir="", 
        listDirs=True, listFiles=False, recursive=True, appendSep=False):
    """
    Return a list of directory contents found under the source directory.
    """
    logger.debug("CollectDirectories: %s, %s, %s"%(srcDir,baseDir,str(os.path.sep)))
    dirsuffix = ""
    if appendSep: dirsuffix = os.path.sep
    collection = []
    if (baseDir != "") and (not baseDir.endswith(os.path.sep)):
        baseDir = baseDir+os.path.sep
    def CollectDir(path):
        logger.debug("- CollectDir base: %s, path: %s"%(baseDir, path))
        if listDirs: collection.append(path.replace(baseDir,"",1)+dirsuffix)
    def CollectFile(path):
        logger.debug("- CollectFile base: %s, path: %s"%(baseDir, path))
        if listFiles: collection.append(path.replace(baseDir,"",1))
    ScanDirectoriesEx(srcDir, CollectDir, CollectFile, recursive)
    return collection
        


src/r/o/ro-manager-HEAD/src/rocommand/ro_metadata.py   ro-manager(Download)
            if recurse:
                rofiles = filter(notHidden,
                    MiscUtils.ScanDirectories.CollectDirectoryContents(ro_file, 
                          baseDir=basedir,
                          listDirs=includeDirs, 

src/r/o/ro-manager-HEAD/src/rocommand/ro_manifest.py   ro-manager(Download)
        rofiles = filter( notHidden,
                            MiscUtils.ScanDirectories.CollectDirectoryContents(
                                os.path.abspath(ro_file), baseDir=os.path.abspath(ro_dir), 
                                listDirs=False, listFiles=True, recursive=recurse, appendSep=False)
                        )

src/r/o/ro-manager-HEAD/src/rocommand/ro_command.py   ro-manager(Download)
        prep_a = "a: "
        rofiles = MiscUtils.ScanDirectories.CollectDirectoryContents(
                    ro_dir, baseDir=os.path.abspath(ro_dir),
                    listDirs=False, listFiles=True, recursive=True, appendSep=False)
        if not options.hidden:

src/r/o/ro-manager-0.2.20/rocommand/ro_metadata.py   ro-manager(Download)
            if recurse:
                rofiles = filter(notHidden,
                    MiscUtils.ScanDirectories.CollectDirectoryContents(ro_file, 
                          baseDir=basedir,
                          listDirs=includeDirs, 

src/r/o/ro-manager-0.2.20/rocommand/ro_manifest.py   ro-manager(Download)
        rofiles = filter( notHidden,
                            MiscUtils.ScanDirectories.CollectDirectoryContents(
                                os.path.abspath(ro_file), baseDir=os.path.abspath(ro_dir), 
                                listDirs=False, listFiles=True, recursive=recurse, appendSep=False)
                        )

src/r/o/ro-manager-0.2.20/rocommand/ro_command.py   ro-manager(Download)
        prep_a = "a: "
        rofiles = MiscUtils.ScanDirectories.CollectDirectoryContents(
                    ro_dir, baseDir=os.path.abspath(ro_dir),
                    listDirs=False, listFiles=True, recursive=True, appendSep=False)
        if not options.hidden:

src/r/o/ro-manager-HEAD/src/MiscUtils/tests/TestScanDirectories.py   ro-manager(Download)
 
sys.path.append("../..")
from MiscUtils.ScanDirectories import CollectDirectoryContents
from MiscUtils.Functions import compareLists
from MiscUtils import TestUtils
    def testCollectDirsShallow(self):
        dirs     = CollectDirectoryContents(self.srcPath, baseDir=self.basePath, recursive=False)
        expected = [ "resources/TestScanDir1"
                   , "resources/TestScanDir2"
                   , "resources/TestScanFilesSubDir"
    def testCollectDirsRecursive(self):
        dirs     = CollectDirectoryContents(self.srcPath,self.basePath)
        expected = [ "resources/TestScanDir1"
                   , "resources/TestScanDir1/SubDir1a"
                   , "resources/TestScanDir1/SubDir1b"
    def testCollectDirsRecursiveBaseEndswithSep(self):
        dirs     = CollectDirectoryContents(self.srcPath,self.basePath+"/")
        expected = [ "resources/TestScanDir1"
                   , "resources/TestScanDir1/SubDir1a"
                   , "resources/TestScanDir1/SubDir1b"
    def testCollectDirsRecursiveEmptyBase(self):
        dirs     = CollectDirectoryContents(self.srcPath, baseDir="")
        expected = [ self.basePath+"/resources/TestScanDir1"
                   , self.basePath+"/resources/TestScanDir1/SubDir1a"
                   , self.basePath+"/resources/TestScanDir1/SubDir1b"