diff.py: add binary support
This commit is contained in:
parent
f979aa993d
commit
d93404353e
1 changed files with 12 additions and 8 deletions
|
@ -42,12 +42,16 @@ type = "installe"
|
|||
+++
|
||||
""")
|
||||
for filename in FILES:
|
||||
with open(join(OLD_DIR, filename[1:]), 'r') as ori:
|
||||
ori_content = ori.readlines()
|
||||
with open(join(NEW_DIR, filename[1:]), 'r') as new:
|
||||
new_content = new.readlines()
|
||||
print(f'- mise à jour du fichier {filename} :\n')
|
||||
print('```diff')
|
||||
for line in unified_diff(ori_content, new_content, fromfile=filename, tofile=filename):
|
||||
print(line.rstrip())
|
||||
print('```')
|
||||
try:
|
||||
with open(join(OLD_DIR, filename[1:]), 'r') as ori:
|
||||
ori_content = ori.readlines()
|
||||
with open(join(NEW_DIR, filename[1:]), 'r') as new:
|
||||
new_content = new.readlines()
|
||||
except UnicodeDecodeError:
|
||||
print('fichier binaire')
|
||||
else:
|
||||
print('```diff')
|
||||
for line in unified_diff(ori_content, new_content, fromfile=filename, tofile=filename):
|
||||
print(line.rstrip())
|
||||
print('```')
|
||||
|
|
Loading…
Reference in a new issue