Repository: Avaiga/taipy
File: taipy/gui_core/_adapters.py (Python)

Code before:
                        if scenario.properties
                        else [],
                        [
                            (
                                s.get_simple_label(),
                                [t.id for t in s.tasks.values()] if hasattr(s, "tasks") else [],
                                _get_reason(is_submittable(s), "Sequence not submittable"),
                                _get_reason(is_editable(s), "Sequence not editable"),
                            )
                            for s in scenario.sequences.values()
                        ]
                        if hasattr(scenario, "sequences") and scenario.sequences
                        else [],
                        {t.id: t.get_simple_label() for t in scenario.tasks.values()}
                        if hasattr(scenario, "tasks")
                        else {},
                        list(scenario.properties.get("authorized_tags", [])) if scenario.properties else [],
                        _get_reason(is_deletable(scenario), "Scenario not deletable"),
                        _get_reason(is_promotable(scenario), "Scenario not promotable"),
                        _get_reason(is_submittable(scenario), "Scenario not submittable"),
                        _get_reason(is_readable(scenario), "Scenario not readable"),
                        _get_reason(is_editable(scenario), "Scenario not editable"),
                    ]
            except Exception as e:
                if not _is_invalidCredentials_exception(e):
                    _warn(f"Access to scenario ({data.id if hasattr(data, 'id') else 'No_id'}) failed", e)

        return None

    @staticmethod
    def get_hash():
        return _TaipyBase._HOLDER_PREFIX + "Sc"


class _GuiCoreScenarioDagAdapter(_TaipyBase):
    @staticmethod
    def get_entity_type(node: t.Any):
        return DataNode.__name__ if isinstance(node.entity, DataNode) else node.type

    def get(self):
        data = super().get()
        if isinstance(data, (list, tuple)) and len(data) == 1:
            data = data[0]
        if isinstance(data, Scenario):
            try:
                if scenario := core_get(data.id):
                    dag = scenario._get_dag()
                    nodes = {}
                    for id, dag_node in dag.nodes.items():
                        entityType = _GuiCoreScenarioDagAdapter.get_entity_type(dag_node)
                        cat = nodes.get(entityType)

Review comment (suggestion):
I would really prefer something clearer:
`_warn(f"Access to scenario '{data.id}'" if hasattr(data, 'id') else "Access to anonymous scenario"})`
... and everywhere this occurs

Code after:
                        if scenario.properties
                        else [],
                        [
                            (
                                s.get_simple_label(),
                                [t.id for t in s.tasks.values()] if hasattr(s, "tasks") else [],
                                _get_reason(is_submittable(s), "Sequence not submittable"),
                                _get_reason(is_editable(s), "Sequence not editable"),
                            )
                            for s in scenario.sequences.values()
                        ]
                        if hasattr(scenario, "sequences") and scenario.sequences
                        else [],
                        {t.id: t.get_simple_label() for t in scenario.tasks.values()}
                        if hasattr(scenario, "tasks")
                        else {},
                        list(scenario.properties.get("authorized_tags", [])) if scenario.properties else [],
                        _get_reason(is_deletable(scenario), "Scenario not deletable"),
                        _get_reason(is_promotable(scenario), "Scenario not promotable"),
                        _get_reason(is_submittable(scenario), "Scenario not submittable"),
                        _get_reason(is_readable(scenario), "Scenario not readable"),
                        _get_reason(is_editable(scenario), "Scenario not editable"),
                    ]
            except Exception as e:
                if not _is_invalidCredentials_exception(e):
                    _warn(
                        f"Access to scenario '{data.id}'" if hasattr(data, "id") else "Access to anonymous scenario", e
                    )

        return None

    @staticmethod
    def get_hash():
        return _TaipyBase._HOLDER_PREFIX + "Sc"


class _GuiCoreScenarioDagAdapter(_TaipyBase):
    @staticmethod
    def get_entity_type(node: t.Any):
        return DataNode.__name__ if isinstance(node.entity, DataNode) else node.type

    def get(self):
        data = super().get()
        if isinstance(data, (list, tuple)) and len(data) == 1:
            data = data[0]
        if isinstance(data, Scenario):
            try:
                if scenario := core_get(data.id):
                    dag = scenario._get_dag()
                    nodes = {}
                    for id, dag_node in dag.nodes.items():