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")
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