Exemple #1
0
 def testFindCollect(self):
     # Get files plus their size
     file_search = find_files(
         self.folder_diff_files, 
         Match(filetype='f', name='1*'),
         collect_size,
     )
     for name, size in file_search:
         self.assertTrue(size > 0)
Exemple #2
0
 def testFind(self):
     # Just search.
     pathnames = [name for name in find_files(self.folder)]        
     self.assertTrue(len(pathnames) > 0)        
     # Search for directories in folder with files only, then search 
     # for files.
     file_search = find_files(self.folder_with_files, Match(filetype='d'))
     pathnames = [name for name in file_search]
     self.assertEquals(len(pathnames), 0)
     file_search = find_files(self.folder_with_files, Match(filetype='f'))
     pathnames = [name for name in file_search]
     self.assertTrue(len(pathnames) > 0)        
     # Search by fnmatch pattern, i.e. wildcard.
     file_search = find_files(
         self.folder_with_files, Match(filetype='f', name='1*'))
     pathnames = [name for name in file_search]        
     self.assertTrue(len(pathnames) > 1)
     condition = lambda pn: os.path.basename(pn).startswith('1')
     self.assertEquals(len(filter(condition, pathnames)), len(pathnames))