Beispiel #1
0
def _diff_archives (archive1, archive2, **kwargs):
    """Show differences between two archives."""
    if util.is_same_file(archive1, archive2):
        msg = "no differences found: archive `%s' and `%s' are the same files"
        print msg % (archive1, archive2)
        return 0
    diff = util.find_program("diff")
    if not diff:
        msg = "The diff(1) program is required for showing archive differences, please install it."
        raise util.PatoolError(msg)
    tmpdir1 = util.tmpdir()
    try:
        path1 = _handle_archive(archive1, 'extract', outdir=tmpdir1, **kwargs)
        tmpdir2 = util.tmpdir()
        try:
            path2 = _handle_archive(archive2, 'extract', outdir=tmpdir2, **kwargs)
            return util.run([diff, "-urN", path1, path2])
        finally:
            shutil.rmtree(tmpdir2, onerror=rmtree_log_error)
    finally:
        shutil.rmtree(tmpdir1, onerror=rmtree_log_error)
Beispiel #2
0
 def test_samefile3 (self):
     parentdir = os.path.dirname(__file__)
     filename1 = os.path.dirname(parentdir)
     filename2 = os.path.join(parentdir, '.')
     self.assertFalse(util.is_same_file(filename1, filename2))
     self.assertFalse(util.is_same_filename(filename1, filename2))
Beispiel #3
0
 def test_samefile1 (self):
     filename1 = filename2 = __file__
     self.assertTrue(util.is_same_filename(filename1, filename2))
     self.assertTrue(util.is_same_file(filename1, filename2))
Beispiel #4
0
 def test_samefile3(self):
     parentdir = os.path.dirname(__file__)
     filename1 = os.path.dirname(parentdir)
     filename2 = os.path.join(parentdir, '.')
     self.assertFalse(util.is_same_file(filename1, filename2))
     self.assertFalse(util.is_same_filename(filename1, filename2))
Beispiel #5
0
 def test_samefile1(self):
     filename1 = filename2 = __file__
     self.assertTrue(util.is_same_filename(filename1, filename2))
     self.assertTrue(util.is_same_file(filename1, filename2))