Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import os
  4. import hashlib
  5.  
  6. def FileCompare(file1, file2):
  7. f1 = open(file1, 'r')
  8. f2 = open(file2, 'r')
  9. hash1 = hashlib.md5(f1.read()).hexdigest()
  10. hash2 = hashlib.md5(f2.read()).hexdigest()
  11. f1.close()
  12. f2.close()
  13. if hash1 == hash2:
  14. #Compare file modification dates
  15. mod1 = os.stat(f1).st_mtime
  16. mod2 = os.stat(f2).st_mtime
  17. if mod1 > mod2 :
  18. return file1
  19. return file2
Add Comment
Please, Sign In to add comment