def testRecursiveWithCachefiles( self ): """ Check return value of multilevel dir tree with empty toplevel dir""" PD = ProcessDir( TestDirMultilevelDirsWithCache ) Res = PD.Process( UseCache=True ) ExpRes = FileCache( Data = TestDirMultilevelDirsWithCache_list ) Res.getAllEntries().sort(lambda x,y : cmp(x['directory'], y['directory'])) self.assertEqual( Res.getNumberOfEntries(), ExpRes.getNumberOfEntries() ) self.assertTrue( Res.getAllEntries() == ExpRes.getAllEntries() )
def main(): opt = ParseCmdLineOptions() # Function to call at each iteration if not opt.verbose: PF = None else: PF = ProgressIndicator # Read or process the master directory if opt.MasterList: print "Retrieving information from file:", opt.MasterList MasterCache = FileCache() MasterCache.loadCache( opt.MasterList ) else: print "Processing master directory" MasterCache = ProcessDir( opt.MasterDir ).Process( ProgressFunction = PF, UseCache = opt.useCache, LinksAreFatal = not opt.AllowLinks ) # save dirlist file? if opt.DumpFile: print "Saving masterlist to file:", opt.DumpFile MasterCache.saveCache( Filename = opt.DumpFile, UseFullPath = True ) # After master dir is don, process second dir and compare. print "Processing secondary directory" SecCache = ProcessDir( opt.SecondaryDir).Process( CompareList=MasterCache, ProgressFunction = PF, UseCache = opt.useCache, LinksAreFatal = not opt.AllowLinks ) # and output print "Dumping duplicates list (if any)" if opt.MasterDir == opt.SecondaryDir: ShowDuplicatesSelfCompare( SecCache ) else: ShowDuplicates( SecCache, MasterCache ) # optionally delete duplicates if opt.deletedups: if opt.MasterDir == opt.SecondaryDir: print "Duplicates will only be erased from secondary (and Sec. and master are the same)" else: print "Deleting duplicates" DeleteByList( SecCache, VerboseFunction = OutputToStderr ) return 0