-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.py
More file actions
31 lines (27 loc) · 1010 Bytes
/
diff.py
File metadata and controls
31 lines (27 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import bsdiff4
import sys
def main():
args = sys.argv
isApplying = False
files = []
for arg in args[1:]:
if arg == "-h" or arg == "-help":
print("Usage:")
print(" python diff.py [-apply | -generate] sourcefile destfile patchfile")
elif arg == "-apply":
isApplying = True
elif arg == "-generate":
isApplying == False
else:
files.append(arg)
if len(files) < 3:
print("Not enough arguments. Please include the source file, destination file, and patch file paths")
print("Usage:")
print(" python lz10.py [-compress | -decompress] infile outfile")
if isApplying:
print("Patching file "+files[0]+" to "+files[1])
bsdiff4.file_patch(files[0], files[1], files[2])
else:
print("Generating diff file between "+files[0]+" and "+files[1]+" to "+files[2])
bsdiff4.file_diff(files[0], files[1], files[2])
if __name__ == "__main__": main()