FIX: sorting now on all module list
This commit is contained in:
parent
19a0264c67
commit
ab5f5344c1
@ -6,13 +6,13 @@ import re
|
||||
import shutil
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
from operator import itemgetter, attrgetter
|
||||
from pytablewriter import AsciiDocTableWriter
|
||||
|
||||
|
||||
def asciidoc_json_dump(list, name, steps, Pmodules_db_path):
|
||||
def asciidoc_json_dump(list, name, steps, Pmodules_db_path, Pmodules_states):
|
||||
matrix = []
|
||||
matrix_db = []
|
||||
matrix_sorted = []
|
||||
temp_matrix_db = []
|
||||
|
||||
# Check the existing database
|
||||
@ -55,6 +55,13 @@ def asciidoc_json_dump(list, name, steps, Pmodules_db_path):
|
||||
with open(db_file, "w") as f:
|
||||
json.dump(matrix, f)
|
||||
|
||||
for state in [x.strip() for x in Pmodules_states]:
|
||||
matrix_sorted += sorted(
|
||||
sorted([x for x in matrix if state in x]),
|
||||
key=lambda x: (x[-1], x[0]),
|
||||
)
|
||||
matrix = matrix_sorted
|
||||
|
||||
# Dump asciidoc file
|
||||
writer = AsciiDocTableWriter(
|
||||
table_name=name.capitalize() + " modules",
|
||||
@ -102,14 +109,6 @@ def db_check_diff(current_pmodule_state, Pmodules_db_path, Pmodules_states):
|
||||
)
|
||||
old_db = set(" ".join(i.split()) for i in old_pmodule_state.splitlines())
|
||||
all_module_list = list(current_db)
|
||||
all_module_list_sorted = sorted([x for x in all_module_list if " stable" in x])
|
||||
all_module_list_sorted += sorted(
|
||||
[x for x in all_module_list if "unstable" in x]
|
||||
)
|
||||
all_module_list_sorted += sorted(
|
||||
[x for x in all_module_list if "deprecated" in x]
|
||||
)
|
||||
all_module_list = all_module_list_sorted
|
||||
|
||||
# We have to check the differences between the pmodule states.
|
||||
if compare_states_sha(current_pmodule_state, old_pmodule_state, current_sha):
|
||||
@ -132,7 +131,9 @@ def db_check_diff(current_pmodule_state, Pmodules_db_path, Pmodules_states):
|
||||
Pmodules_db_path,
|
||||
)
|
||||
else:
|
||||
print_to_asciidoc(all_module_list, [], [], [], Pmodules_db_path)
|
||||
print_to_asciidoc(
|
||||
all_module_list, [], [], [], Pmodules_db_path, Pmodules_states
|
||||
)
|
||||
|
||||
# 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(
|
||||
@ -147,11 +148,16 @@ def print_to_asciidoc(
|
||||
deleted_module_list,
|
||||
changed_module_list,
|
||||
Pmodules_db_path,
|
||||
Pmodules_states,
|
||||
):
|
||||
asciidoc_json_dump(all_module_list, "all", 1, Pmodules_db_path)
|
||||
asciidoc_json_dump(new_module_list, "new", 1, Pmodules_db_path)
|
||||
asciidoc_json_dump(deleted_module_list, "deleted", 1, Pmodules_db_path)
|
||||
asciidoc_json_dump(changed_module_list, "changed", 2, Pmodules_db_path)
|
||||
asciidoc_json_dump(all_module_list, "all", 1, Pmodules_db_path, Pmodules_states)
|
||||
asciidoc_json_dump(new_module_list, "new", 1, Pmodules_db_path, Pmodules_states)
|
||||
asciidoc_json_dump(
|
||||
deleted_module_list, "deleted", 1, Pmodules_db_path, Pmodules_states
|
||||
)
|
||||
asciidoc_json_dump(
|
||||
changed_module_list, "changed", 2, Pmodules_db_path, Pmodules_states
|
||||
)
|
||||
|
||||
|
||||
def print_pmodules_differences(
|
||||
@ -199,6 +205,7 @@ def print_pmodules_differences(
|
||||
deleted_module_list,
|
||||
changed_module_list,
|
||||
Pmodules_db_path,
|
||||
Pmodules_states,
|
||||
)
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ def main():
|
||||
|
||||
# Global variables
|
||||
Pmodules_db_path = "/opt/psi/var/cache/pmodules_db/"
|
||||
Pmodules_states = [" deprecated", " stable", " unstable"]
|
||||
Pmodules_states = [" stable", " unstable", " deprecated"]
|
||||
|
||||
# Main search to analyse
|
||||
module_cmd = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user