summaryrefslogtreecommitdiff
path: root/pyvyos/utils/paths.py
blob: b591b09e1d8dac7149f1cbdd01b5f60170a84a3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Path building utilities for VyOS configuration paths."""

from typing import List, Union


def build_path(*segments: Union[str, List[str]]) -> List[str]:
    """
    Build a configuration path from segments.
    
    Args:
        *segments: Path segments (strings or lists of strings)
    
    Returns:
        Flattened list of path segments
    
    Examples:
        build_path("interfaces", "ethernet", "eth0") 
        -> ["interfaces", "ethernet", "eth0"]
        
        build_path(["interfaces", "ethernet"], "address", "192.168.1.1/24")
        -> ["interfaces", "ethernet", "address", "192.168.1.1/24"]
    """
    result = []
    for segment in segments:
        if isinstance(segment, list):
            result.extend(segment)
        else:
            result.append(str(segment))
    return result