Amélioration avec __init__.py
This commit is contained in:
parent
c55d478660
commit
4bb06a4801
@ -1,2 +1,4 @@
|
||||
# __init__.py – app/fiches
|
||||
from .interface import interface_analyse
|
||||
|
||||
__all_ = [interface_analyse]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# __init__.py – app/personnalisation
|
||||
|
||||
from .interface import interface_personnalisation
|
||||
from .ajout import ajouter_produit
|
||||
from .modification import modifier_produit
|
||||
from .import_export import importer_exporter_graph
|
||||
|
||||
__all__ = [
|
||||
"interface_personnalisation"
|
||||
]
|
||||
|
||||
@ -2,11 +2,12 @@
|
||||
|
||||
import streamlit as st
|
||||
from utils.translations import _
|
||||
from .ajout import ajouter_produit
|
||||
from .modification import modifier_produit
|
||||
from .import_export import importer_exporter_graph
|
||||
from utils.widgets import html_expander
|
||||
|
||||
from app.personnalisation.utils import ajouter_produit
|
||||
from app.personnalisation.utils import modifier_produit
|
||||
from app.personnalisation.utils import importer_exporter_graph
|
||||
|
||||
def interface_personnalisation(G):
|
||||
st.markdown(f"# {str(_('pages.personnalisation.title'))}")
|
||||
html_expander(f"{str(_('pages.personnalisation.help'))}", content="\n".join(_("pages.personnalisation.help_content")), open_by_default=False, details_class="details_introduction")
|
||||
|
||||
11
app/personnalisation/utils/__init__.py
Normal file
11
app/personnalisation/utils/__init__.py
Normal file
@ -0,0 +1,11 @@
|
||||
# __init__.py – app/personnalisation
|
||||
|
||||
from .ajout import ajouter_produit
|
||||
from .modification import modifier_produit
|
||||
from .import_export import importer_exporter_graph
|
||||
|
||||
__all__ = [
|
||||
"ajouter_produit",
|
||||
"modifier_produit",
|
||||
"importer_exporter_graph"
|
||||
]
|
||||
@ -1,2 +1,34 @@
|
||||
# __init__.py – app/fiches
|
||||
from .interface import interface_plan_d_action
|
||||
# app/plan_d_action/__init__.py
|
||||
|
||||
from .utils.data.plan_d_action import initialiser_interface
|
||||
|
||||
from .utils.interface.parser import preparer_graphe
|
||||
from .utils.interface.niveau_utils import extraire_niveaux
|
||||
from .utils.interface.selection import (
|
||||
selectionner_minerais,
|
||||
selectionner_noeuds,
|
||||
extraire_chemins_selon_criteres
|
||||
)
|
||||
from .utils.interface.export import (
|
||||
exporter_graphe_filtre,
|
||||
extraire_liens_filtres
|
||||
)
|
||||
from .utils.interface.visualization import remplacer_par_badge
|
||||
from .utils.interface.config import (
|
||||
niveau_labels,
|
||||
JOBS
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"initialiser_interface",
|
||||
"preparer_graphe",
|
||||
"extraire_niveaux",
|
||||
"selectionner_minerais",
|
||||
"selectionner_noeuds",
|
||||
"extraire_chemins_selon_criteres",
|
||||
"exporter_graphe_filtre",
|
||||
"extraire_liens_filtres",
|
||||
"remplacer_par_badge",
|
||||
"niveau_labels",
|
||||
"JOBS"
|
||||
]
|
||||
|
||||
@ -20,22 +20,17 @@ from batch_ia import (
|
||||
generate_report,
|
||||
)
|
||||
|
||||
from app.plan_d_action.utils.data.plan_d_action import initialiser_interface
|
||||
|
||||
from app.plan_d_action.utils.interface.parser import preparer_graphe
|
||||
from app.plan_d_action.utils.interface.niveau_utils import extraire_niveaux
|
||||
from app.plan_d_action.utils.interface.selection import (
|
||||
from app.plan_d_action import (
|
||||
initialiser_interface,
|
||||
preparer_graphe,
|
||||
extraire_niveaux,
|
||||
selectionner_minerais,
|
||||
selectionner_noeuds,
|
||||
extraire_chemins_selon_criteres
|
||||
)
|
||||
from app.plan_d_action.utils.interface.export import (
|
||||
extraire_chemins_selon_criteres,
|
||||
exporter_graphe_filtre,
|
||||
extraire_liens_filtres
|
||||
)
|
||||
from app.plan_d_action.utils.interface.visualization import remplacer_par_badge
|
||||
from app.plan_d_action.utils.interface.config import (
|
||||
extraire_liens_filtres,
|
||||
niveau_labels,
|
||||
remplacer_par_badge,
|
||||
JOBS
|
||||
)
|
||||
|
||||
|
||||
@ -1,8 +1,29 @@
|
||||
from .config import (
|
||||
PRECONISATIONS,
|
||||
INDICATEURS
|
||||
INDICATEURS,
|
||||
poids_operation
|
||||
)
|
||||
from .data_utils import(
|
||||
from .data_processing import parse_chains_md
|
||||
from .data_utils import (
|
||||
set_vulnerability,
|
||||
colorer_couleurs,
|
||||
set_vulnerability
|
||||
initialiser_seuils
|
||||
)
|
||||
from .pda_interface import (
|
||||
afficher_bloc_ihh_isg,
|
||||
afficher_description,
|
||||
afficher_caracteristiques_minerai
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"PRECONISATIONS",
|
||||
"INDICATEURS",
|
||||
"poids_operation",
|
||||
"parse_chains_md",
|
||||
"set_vulnerability",
|
||||
"colorer_couleurs",
|
||||
"initialiser_seuils",
|
||||
"afficher_bloc_ihh_isg",
|
||||
"afficher_description",
|
||||
"afficher_caracteristiques_minerai"
|
||||
]
|
||||
|
||||
@ -14,13 +14,14 @@ def afficher_bloc_ihh_isg(titre, ihh, isg, details_content=""):
|
||||
conteneur, = st.columns([1], gap="small", border=True)
|
||||
with conteneur:
|
||||
st.markdown("#### Vulnérabilité combinée IHH-ISG")
|
||||
afficher_section_texte(lines, "#### Vulnérabilité combinée IHH-ISG", "###")
|
||||
contenu = afficher_section_texte(lines, "#### Vulnérabilité combinée IHH-ISG", "###")
|
||||
st.markdown(contenu)
|
||||
|
||||
# 2. Afficher ISG des pays impliqués
|
||||
if "##### ISG des pays impliqués" in details_content:
|
||||
print(details_content)
|
||||
st.markdown("#### ISG des pays impliqués")
|
||||
afficher_section_avec_tableau(lines, "##### ISG des pays impliqués")
|
||||
contenu = afficher_section_avec_tableau(lines, "##### ISG des pays impliqués")
|
||||
st.markdown(contenu)
|
||||
|
||||
# Afficher le résumé ISG combiné
|
||||
for line in lines:
|
||||
@ -33,22 +34,26 @@ def afficher_bloc_ihh_isg(titre, ihh, isg, details_content=""):
|
||||
st.markdown("#### Indice de Herfindahl-Hirschmann")
|
||||
|
||||
# Tableau de résumé IHH
|
||||
afficher_section_avec_tableau(lines, "#### Indice de Herfindahl-Hirschmann")
|
||||
contenu = afficher_section_avec_tableau(lines, "#### Indice de Herfindahl-Hirschmann")
|
||||
st.markdown(contenu)
|
||||
|
||||
# IHH par entreprise
|
||||
if "##### IHH par entreprise (acteurs)" in details_content:
|
||||
st.markdown("##### IHH par entreprise (acteurs)")
|
||||
afficher_section_texte(lines, "##### IHH par entreprise (acteurs)", "##### IHH par pays")
|
||||
contenu = afficher_section_texte(lines, "##### IHH par entreprise (acteurs)", "##### IHH par pays")
|
||||
st.markdown(contenu)
|
||||
|
||||
# IHH par pays
|
||||
if "##### IHH par pays" in details_content:
|
||||
st.markdown("##### IHH par pays")
|
||||
afficher_section_texte(lines, "##### IHH par pays", "##### En résumé")
|
||||
contenu = afficher_section_texte(lines, "##### IHH par pays", "##### En résumé")
|
||||
st.markdown(contenu)
|
||||
|
||||
# En résumé
|
||||
if "##### En résumé" in details_content:
|
||||
st.markdown("##### En résumé")
|
||||
afficher_section_texte(lines, "##### En résumé", "####")
|
||||
contenu = afficher_section_texte(lines, "##### En résumé", "####")
|
||||
st.markdown(contenu)
|
||||
|
||||
def afficher_section_avec_tableau(lines, section_start, section_end=None):
|
||||
"""Affiche une section contenant un tableau"""
|
||||
@ -71,11 +76,13 @@ def afficher_section_avec_tableau(lines, section_start, section_end=None):
|
||||
break
|
||||
|
||||
if table_lines:
|
||||
st.markdown('\n'.join(table_lines))
|
||||
contenu = '\n'.join(table_lines)
|
||||
return contenu
|
||||
|
||||
def afficher_section_texte(lines, section_start, section_end_marker=None):
|
||||
"""Affiche le texte d'une section sans les tableaux"""
|
||||
in_section = False
|
||||
contenu_md = []
|
||||
|
||||
for line in lines:
|
||||
if section_start in line:
|
||||
@ -86,7 +93,10 @@ def afficher_section_texte(lines, section_start, section_end_marker=None):
|
||||
elif in_section and line.startswith('#') and section_start not in line:
|
||||
break
|
||||
elif in_section and line.strip() and not line.strip().startswith('|'):
|
||||
st.markdown(line)
|
||||
contenu_md.append(line + '\n')
|
||||
|
||||
contenu = '\n'.join(contenu_md)
|
||||
return contenu
|
||||
|
||||
def afficher_description(titre, description):
|
||||
st.markdown(f"## {titre}")
|
||||
@ -133,35 +143,34 @@ def afficher_caracteristiques_minerai(minerai, mineraux_data, details_content=""
|
||||
conteneur, = st.columns([1], gap="small", border=True)
|
||||
with conteneur:
|
||||
st.markdown("#### Vulnérabilité combinée ICS-IVC")
|
||||
afficher_section_texte(lines, "#### Vulnérabilité combinée ICS-IVC", "####")
|
||||
contenu = afficher_section_texte(lines, "#### Vulnérabilité combinée ICS-IVC", "####")
|
||||
st.markdown(contenu)
|
||||
|
||||
# 1. Afficher la section ICS complète
|
||||
if "#### ICS" in details_content:
|
||||
st.markdown("#### ICS")
|
||||
|
||||
# Afficher le premier tableau ICS (avec toutes les colonnes)
|
||||
afficher_section_avec_tableau(lines, "#### ICS", "##### Valeurs d'ICS par composant")
|
||||
contenu = afficher_section_avec_tableau(lines, "#### ICS", "##### Valeurs d'ICS par composant")
|
||||
st.markdown(contenu)
|
||||
|
||||
# Afficher la sous-section "Valeurs d'ICS par composant"
|
||||
if "##### Valeurs d'ICS par composant" in details_content:
|
||||
st.markdown("##### Valeurs d'ICS par composant")
|
||||
afficher_section_avec_tableau(lines, "##### Valeurs d'ICS par composant", "**ICS moyen")
|
||||
contenu = afficher_section_avec_tableau(lines, "##### Valeurs d'ICS par composant", "**ICS moyen")
|
||||
|
||||
# Afficher le résumé ICS moyen
|
||||
for line in lines:
|
||||
if "**ICS moyen" in line:
|
||||
st.markdown(line)
|
||||
contenu = contenu + line
|
||||
break
|
||||
|
||||
st.markdown(contenu)
|
||||
|
||||
# 2. Afficher la section IVC complète
|
||||
if "#### IVC" in details_content:
|
||||
st.markdown("#### IVC")
|
||||
|
||||
# Afficher la valeur IVC principale
|
||||
for line in lines:
|
||||
if "**IVC:" in line:
|
||||
st.markdown(line)
|
||||
break
|
||||
|
||||
# Afficher tous les détails de la section IVC
|
||||
afficher_section_texte(lines, "#### IVC", "#### Vulnérabilité combinée ICS-IVC")
|
||||
contenu = afficher_section_texte(lines, "#### IVC", "#### Vulnérabilité combinée ICS-IVC")
|
||||
st.markdown(contenu)
|
||||
|
||||
@ -1,22 +1,18 @@
|
||||
import streamlit as st
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from app.plan_d_action.utils.data.config import (
|
||||
from app.plan_d_action.utils.data import (
|
||||
PRECONISATIONS,
|
||||
INDICATEURS,
|
||||
poids_operation
|
||||
)
|
||||
from app.plan_d_action.utils.data.data_processing import parse_chains_md
|
||||
from app.plan_d_action.utils.data.data_utils import (
|
||||
poids_operation,
|
||||
parse_chains_md,
|
||||
set_vulnerability,
|
||||
colorer_couleurs
|
||||
)
|
||||
from app.plan_d_action.utils.data.pda_interface import (
|
||||
colorer_couleurs,
|
||||
afficher_bloc_ihh_isg,
|
||||
afficher_description,
|
||||
afficher_caracteristiques_minerai
|
||||
afficher_caracteristiques_minerai,
|
||||
initialiser_seuils
|
||||
)
|
||||
from app.plan_d_action.utils.data.data_utils import initialiser_seuils
|
||||
|
||||
def calcul_poids_chaine(poids_A, poids_F, poids_T, poids_E, poids_M):
|
||||
poids_total = (\
|
||||
@ -86,12 +82,25 @@ def tableau_de_bord(chains, produits, composants, mineraux, seuils):
|
||||
|
||||
produits_disponibles = sorted({c["produit"] for c in chains})
|
||||
sel_prod = st.selectbox("Produit", produits_disponibles, index=produits_disponibles.index(st.session_state.sel_prod) if st.session_state.sel_prod else 0)
|
||||
if sel_prod != st.session_state.sel_prod:
|
||||
st.session_state.sel_prod = sel_prod
|
||||
st.session_state.sel_comp = None
|
||||
st.session_state.sel_miner = None
|
||||
st.rerun()
|
||||
|
||||
composants_dispo = sorted({c["composant"] for c in chains if c["produit"] == sel_prod})
|
||||
sel_comp = st.selectbox("Composant", composants_dispo, index=composants_dispo.index(st.session_state.sel_comp) if st.session_state.sel_comp else 0)
|
||||
if sel_comp != st.session_state.sel_comp:
|
||||
st.session_state.sel_comp = sel_comp
|
||||
st.session_state.sel_miner = None
|
||||
st.rerun()
|
||||
|
||||
mineraux_dispo = sorted({c["minerai"] for c in chains if c["produit"] == sel_prod and c["composant"] == sel_comp})
|
||||
sel_miner = st.selectbox("Minerai", mineraux_dispo, index=mineraux_dispo.index(st.session_state.sel_miner) if st.session_state.sel_miner else 0)
|
||||
if sel_miner != st.session_state.sel_miner:
|
||||
st.session_state.sel_miner = sel_miner
|
||||
st.rerun()
|
||||
|
||||
with col_right:
|
||||
top_chains = analyser_chaines(chains, produits, composants, mineraux, seuils, top_n=5)
|
||||
st.markdown("**<u>Top chaînes critiques pour sélection rapide</u>**", unsafe_allow_html=True)
|
||||
|
||||
@ -1,17 +1,5 @@
|
||||
from .parser import preparer_graphe
|
||||
from .niveau_utils import extraire_niveaux
|
||||
from .selection import (
|
||||
selectionner_minerais,
|
||||
selectionner_noeuds,
|
||||
extraire_chemins_selon_criteres
|
||||
)
|
||||
from .export import (
|
||||
exporter_graphe_filtre,
|
||||
extraire_liens_filtres
|
||||
)
|
||||
from .visualization import remplacer_par_badge
|
||||
from .config import (
|
||||
niveau_labels,
|
||||
JOBS,
|
||||
CORRESPONDANCE_COULEURS
|
||||
)
|
||||
from .config import CORRESPONDANCE_COULEURS
|
||||
|
||||
__all__ = [
|
||||
"CORRESPONDANCE_COULEURS"
|
||||
]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import re
|
||||
from app.plan_d_action.utils.interface.config import CORRESPONDANCE_COULEURS
|
||||
from app.plan_d_action.utils.interface import CORRESPONDANCE_COULEURS
|
||||
|
||||
def remplacer_par_badge(markdown_text, correspondance=CORRESPONDANCE_COULEURS):
|
||||
# Échappe les mots à remplacer s'ils contiennent des accents ou espaces
|
||||
|
||||
10897
app/plan_d_action/utils/jobs/f7e9ba2e.md
Normal file
10897
app/plan_d_action/utils/jobs/f7e9ba2e.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
# batch_ia/__init__.py
|
||||
|
||||
# config.py
|
||||
from .utils.config import TEMPLATE_PATH, load_config
|
||||
from .utils.config import TEMPLATE_PATH, load_config, session_uuid, TEMP_SECTIONS
|
||||
|
||||
# files.py
|
||||
from .utils.files import write_report
|
||||
@ -18,6 +18,8 @@ from .utils.sections import generate_report
|
||||
|
||||
__all__ = [
|
||||
"TEMPLATE_PATH",
|
||||
"session_uuid",
|
||||
"TEMP_SECTIONS",
|
||||
"load_config",
|
||||
"write_report",
|
||||
"parse_graphs",
|
||||
|
||||
@ -59,15 +59,13 @@ def main(dot_path, output_path):
|
||||
# Écrire le rapport
|
||||
write_report(report, TEMPLATE_PATH)
|
||||
ingest_document(TEMPLATE_PATH)
|
||||
# Générer l'analyse par l'IA du rapport compler
|
||||
# Générer l'analyse par l'IA du rapport complet
|
||||
analyse_finale = nettoyer_texte_fr(ia_analyse(file_names))
|
||||
analyse_fichier = TEMP_SECTIONS / TEMPLATE_PATH.name.replace(".md", " - analyse.md")
|
||||
write_report(analyse_finale, analyse_fichier)
|
||||
|
||||
if generer_rapport_final(TEMPLATE_PATH, analyse_fichier, output_path):
|
||||
supprimer_fichiers(session_uuid)
|
||||
else:
|
||||
print("")
|
||||
|
||||
if __name__ == "__main__":
|
||||
dot_path = Path(sys.argv[1])
|
||||
|
||||
@ -440,11 +440,9 @@ def generate_minerals_section(data, results, config):
|
||||
if first_line.strip().startswith('#'):
|
||||
# Extraire le texte du titre sans les # et les espaces
|
||||
title_text = first_line.strip().lstrip('#').strip()
|
||||
content = f"\n*{title_text}*\n{rest.strip()}"
|
||||
content = f"\n*{title_text}*\n\n{rest.strip()}\n"
|
||||
|
||||
# Ne pas ajouter de contenu vide
|
||||
if content.strip():
|
||||
template.append(content.strip())
|
||||
template.append(content)
|
||||
|
||||
# ICS et IVC combinés
|
||||
if mineral_id in results["ics_ivc_combined"]:
|
||||
|
||||
@ -79,7 +79,7 @@ from app.visualisations import interface_visualisations
|
||||
from app.personnalisation import interface_personnalisation
|
||||
from app.analyse import interface_analyse
|
||||
from app.ia_nalyse import interface_ia_nalyse
|
||||
from app.plan_d_action import interface_plan_d_action
|
||||
from app.plan_d_action.interface import interface_plan_d_action
|
||||
|
||||
# Initialisation des traductions (langue française par défaut)
|
||||
init_translations()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user