Last active
August 29, 2015 14:14
-
-
Save righ/f120eeed5b03f97e83ba to your computer and use it in GitHub Desktop.
dircmp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
import filecmp | |
class Break(Exception): | |
"""for break recursive function | |
""" | |
def dircmp(dir1, dir2): | |
"""compare dictionary | |
return dir1 == dir2 | |
""" | |
def recurse(dircmp): | |
for attr in ( | |
'left_only', 'right_only', | |
'diff_files', 'common_funny', | |
): | |
if getattr(dircmp, attr): | |
raise Break | |
for dircmp in dircmp.subdirs.values(): | |
recurse(dircmp) | |
try: | |
recurse(filecmp.dircmp(dir1, dir2)) | |
except Break: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment