To compare differences between catalogs:
I only compare by name, if the file name of the directory is the same, but the contents of different scripts are considered to be the same file
II There is no round-robin comparison for directories below the directory, just comparing the name of the directory
import sys, osdef difference (seq1, seq2): "" returns only items in seq1 "" "return [i TEM for item in SEQ1 if Item not in Seq2]def Reportdiff (unique1, unique2, dir1, dir2): if not (unique1 or unique2): Print ("dir lists is Identical") else:if unique1:print ("file unique to", dir1) for I TEM in Unique1:print (' ... ', item) if unique2:print ("file unique to", dir2) F or item in Unique2:print ("...", Item) def comparedirs (dir1, dir2): print ("comparing {0} to {1}". format (d ir1, dir2)) if not (os.path.isdir (dir1) and os.path.isdir (dir2)): return else:files1 = Os.listdir (dir 1) files2 = os.listdir (dir2) unique1 = Difference (files1, files2) unique2 = Difference (files2, files1 ) Reportdiff (unique1, unique2, dir1, dir2) if __name__ = = ' __main__ ': comparedirs ('.. /testdir ', '. /testdir1 ')
Python applet compares the differences between catalogs