1#!/usr/bin/env python 2# Copyright 2015 The PDFium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import difflib 7import sys 8 9def main(argv): 10 if len(argv) != 3: 11 print '%s: invalid arguments' % argv[0] 12 return 2 13 filename1 = argv[1] 14 filename2 = argv[2] 15 try: 16 with open(filename1, "r") as f1: 17 str1 = f1.readlines(); 18 with open(filename2, "r") as f2: 19 str2 = f2.readlines(); 20 diffs = difflib.unified_diff( 21 str1, str2, fromfile=filename1, tofile=filename2) 22 except Exception as e: 23 print "something went astray: %s" % e 24 return 1 25 status_code = 0 26 for diff in diffs: 27 sys.stdout.write(diff) 28 status_code = 1 29 return status_code 30 31if __name__ == '__main__': 32 sys.exit(main(sys.argv)) 33