예제 #1
0
 def testFile(self):
     file = File('project.conf')
     self.assertEquals(file.isFile(), True, "is a file expected")
     self.assertEquals(file.isDirectory(), False,
                       "is not a directory expected")
     self.assertEquals(file.getName(), 'project.conf', "invalid name")
     self.assertEquals(file.getPath(), '', "invalid path")
예제 #2
0
파일: Files.py 프로젝트: wlongxiang/noora
    def list(file=None, recursive=False, exclude=None):
        result = []

        if file.exists():
            folder = file.getPath() + os.sep + file.getName()
            fileList = os.listdir(folder)
            fileList.sort()
            for fileItem in fileList:
                pathName = folder + os.sep + fileItem
                candidateFile = File(pathName)
                if candidateFile.isFile() and exclude != "file":
                    result.append(candidateFile)
                if candidateFile.isDirectory() and exclude != "directory":
                    result.append(candidateFile)
                if candidateFile.isDirectory() and recursive == True:
                    recursiveFiles = Files.list(candidateFile, recursive,
                                                exclude)
                    for recursiveFile in recursiveFiles:
                        result.append(recursiveFile)
            #result.sort()
        return result