A
This version would write the diff to disk:
diff
is the differences between two files. This is essential for knowing the exact differences between two files. If we manually look at two files side by side it may happen that we miss small subtleties, so it serves us better to leave that job to a much more strict eye: software. The following gist is probably self explanatory. The difflib
is perhaps an obscure module, worth exploring. If GAE supports difflib I will write a diff generator at some point (one that offers a download generated clientside)
This file contains hidden or 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
import difflib | |
old_file = 'info_best_practice.rst' | |
new_file = 'info_best_practice_dest.rst' | |
a = open(old_file).readlines() | |
b = open(new_file).readlines() | |
diff_string = difflib.unified_diff(a=a, b=b) #, fromfile=old_file, tofile=new_file) | |
for line in diff_string: | |
print(line) |
This file contains hidden or 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
import difflib | |
fromfile = 'info_best_practice.rst' | |
tofile = 'info_best_practice_dest.rst' | |
diff_file = 'info_best_practice4.diff' | |
a = open(fromfile).readlines() | |
b = open(tofile).readlines() | |
diff_string = difflib.unified_diff(a, b, fromfile, tofile) | |
with open(diff_file, 'w') as d: | |
for line in diff_string: | |
d.write(line) | |