From 25deba629ff9d404aecb6bc62ba6c1d712951756 Mon Sep 17 00:00:00 2001 From: germann_e Date: Tue, 22 Aug 2023 15:53:36 +0200 Subject: [PATCH] TRY: testing if all_modules issue is fixed --- pmodules_tools/db_diff/check.py | 42 ++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pmodules_tools/db_diff/check.py b/pmodules_tools/db_diff/check.py index 7686f53e..f13ba081 100644 --- a/pmodules_tools/db_diff/check.py +++ b/pmodules_tools/db_diff/check.py @@ -93,15 +93,28 @@ def db_check_diff(current_pmodule_state, Pmodules_db_path, Pmodules_states): ) no_current_db = True - # There is a database and we have to check the differences between the pmodule states. - if not no_current_db and compare_states_sha( - current_pmodule_state, old_pmodule_state, current_sha - ): - print_pmodules_differences( - current_pmodule_state, old_pmodule_state, Pmodules_states, Pmodules_db_path + # Make sure the whitespaces in between the module descriptions are always one space only. + # There is a database + if not no_current_db: + current_db = set( + " ".join(i.split()) for i in current_pmodule_state.splitlines() ) - else: - print_to_asciidoc([], [], [], [], Pmodules_db_path) + old_db = set(" ".join(i.split()) for i in old_pmodule_state.splitlines()) + all_module_list = list(current_db) + + # We have to check the differences between the pmodule states. + if compare_states_sha(current_pmodule_state, old_pmodule_state, current_sha): + new_module_list = list(current_db - old_db) + deleted_module_list = list(old_db - current_db) + print_pmodules_differences( + all_module_list, + new_module_list, + deleted_module_list, + Pmodules_states, + Pmodules_db_path, + ) + else: + print_to_asciidoc(all_module_list, [], [], [], Pmodules_db_path) # There is no database available or there are differences with the old pmodule state, writing current state. if no_current_db or compare_states_sha( @@ -124,15 +137,12 @@ def print_to_asciidoc( def print_pmodules_differences( - current_pmodule_state, old_pmodule_state, Pmodules_states, Pmodules_db_path + all_module_list, + new_module_list, + deleted_module_list, + Pmodules_states, + Pmodules_db_path, ): - # Make sure the whitespaces in between the module descriptions are always one space only. - current_db = set(" ".join(i.split()) for i in current_pmodule_state.splitlines()) - old_db = set(" ".join(i.split()) for i in old_pmodule_state.splitlines()) - - all_module_list = list(current_db) - new_module_list = list(current_db - old_db) - deleted_module_list = list(old_db - current_db) changed_module_list = [] # Replace the state of the modules with * for Regex comparison