Skip to content

Instantly share code, notes, and snippets.

@righ
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save righ/f120eeed5b03f97e83ba to your computer and use it in GitHub Desktop.
Save righ/f120eeed5b03f97e83ba to your computer and use it in GitHub Desktop.
dircmp.py
# 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