Coverage for src / lexigram / admin / settings / panel / utils.py: 0%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-11 02:25 +0800

1"""Shared utility functions for the settings panel.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any 

6 

7 

8def map_config_node_type(node: Any) -> str: 

9 """Map a ConfigNode class name to a SettingDefinition storage type string. 

10 

11 Args: 

12 node: Any object whose class name follows the ``*Node`` convention. 

13 

14 Returns: 

15 Lowercase type string (``"string"``, ``"int"``, ``"bool"``, 

16 ``"enum"``, or ``"secret"``). 

17 """ 

18 _type_map: dict[str, str] = { 

19 "StringNode": "string", 

20 "IntNode": "int", 

21 "BooleanNode": "bool", 

22 "EnumNode": "enum", 

23 "SecretNode": "secret", 

24 } 

25 return _type_map.get(node.__class__.__name__, "string") 

26 

27 

28__all__ = ["map_config_node_type"]