예제 #1
0
def dircmp(a, b): # Compare whether two directories are the same
	# To make this as fast as possible, it uses the statcache
	print '  dircmp', a, b
	a_list = dircache.listdir(a)
	b_list = dircache.listdir(b)
	for x in a_list:
		if skipthis(x):
			pass
		elif x not in b_list:
			return 0
		else:
			ax = os.path.join(a, x)
			bx = os.path.join(b, x)
			if statcache.isdir(ax) and statcache.isdir(bx):
				if not dircmp(ax, bx): return 0
			else:
				try:
					if not cmpcache.cmp(ax, bx): return 0
				except (RuntimeError, os.error):
					return 0
	for x in b_list:
		if skipthis(x):
			pass
		elif x not in a_list:
			return 0
	return 1
예제 #2
0
def dircmp(a, b): # Compare whether two directories are the same
	# To make this as fast as possible, it uses the statcache
	print '  dircmp', a, b
	a_list = dircache.listdir(a)
	b_list = dircache.listdir(b)
	for x in a_list:
		if x in skiplist:
			pass
		elif x not in b_list:
			return 0
		else:
			ax = path.cat(a, x)
			bx = path.cat(b, x)
			if statcache.isdir(ax) and statcache.isdir(bx):
				if not dircmp(ax, bx): return 0
			else:
				try:
					if not cmpcache.cmp(ax, bx): return 0
				except posix.error:
					return 0
	for x in b_list:
		if x in skiplist:
			pass
		elif x not in a_list:
			return 0
	return 1
예제 #3
0
def dircmp(a, b):  # Compare whether two directories are the same
    # To make this as fast as possible, it uses the statcache
    print "  dircmp", a, b
    a_list = dircache.listdir(a)
    b_list = dircache.listdir(b)
    for x in a_list:
        if skipthis(x):
            pass
        elif x not in b_list:
            return 0
        else:
            ax = os.path.join(a, x)
            bx = os.path.join(b, x)
            if statcache.isdir(ax) and statcache.isdir(bx):
                if not dircmp(ax, bx):
                    return 0
            else:
                try:
                    if not cmpcache.cmp(ax, bx):
                        return 0
                except (RuntimeError, os.error):
                    return 0
    for x in b_list:
        if skipthis(x):
            pass
        elif x not in a_list:
            return 0
    return 1
예제 #4
0
def cmp(a, b):
    """Compare two files.
    Return:
        0 for equal
        1 for different
        2 for funny cases (can't stat, etc.)"""

    try:
        if cmpcache.cmp(a, b): return 0
        return 1
    except os.error:
        return 2
예제 #5
0
def cmp(a, b):
	try:
		if cmpcache.cmp(a, b): return 0
		return 1
	except posix.error:
		return 2
예제 #6
0
import cmpcache

if cmpcache.cmp("samples/sample.au", "samples/sample.wav"):
    print "files are identical"
else:
    print "files differ!"

## files differ!
예제 #7
0
파일: dircmp.py 프로젝트: mcyril/ravel-ftn
"""A class to build directory diff tools on."""
예제 #8
0
"""A class to build directory diff tools on."""
예제 #9
0
def cmp(a, b):
       try:
               if cmpcache.cmp(a, b): return 0
               return 1
       except posix.error:
               return 2
예제 #10
0
import cmpcache

if cmpcache.cmp("samples/sample.au", "samples/sample.wav"):
    print("files are identical")
else:
    print("files differ!")

## files differ!