From d93404353e8352af9c38a05d05f21ff13cd6536c Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 29 Mar 2022 16:24:52 +0200 Subject: [PATCH] diff.py: add binary support --- .../2022.03.08/base/manual/install/diff.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/seed/applicationservice/2022.03.08/base/manual/install/diff.py b/seed/applicationservice/2022.03.08/base/manual/install/diff.py index 7411444..f5780f6 100755 --- a/seed/applicationservice/2022.03.08/base/manual/install/diff.py +++ b/seed/applicationservice/2022.03.08/base/manual/install/diff.py @@ -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('```')