parse_switchmatrixΒΆ
Parser functions for switch matrix and list file configurations.
This module provides utilities for parsing switch matrix CSV files and list files used in fabric definition. It handles expansion of port definitions, connection mappings, and validation of port configurations.
FunctionsΒΆ
|
Expand the .list file entry into a list of port strings. |
|
Parse a list file and expand the list file information into a list of tuples. |
|
Parse the matrix CSV into a dictionary from destination to source. |
Module ContentsΒΆ
- expandListPorts(port) list[str][source]ΒΆ
Expand the .list file entry into a list of port strings.
- Parameters:
port (str) β The port entry to expand. If it contains β[β, itβs split into multiple entries based on β|β.
- Raises:
ValueError β If the port entry contains β[β or β{β without matching closing bracket β]β/β}β.
- Returns:
The expanded list of port strings.
- parseList(filePath: Path, collect: Literal['pair'] = 'pair') list[tuple[str, str]][source]ΒΆ
- parseList(filePath: Path, collect: Literal['source', 'sink']) dict[str, list[str]]
Parse a list file and expand the list file information into a list of tuples.
- Parameters:
filePath (Path) β The path to the list file to parse.
collect (Literal["pair", "source", "sink"], optional) β Collect value by source, sink or just as (source, sink) pair. Defaults to βpairβ.
- Raises:
FileNotFoundError β The file does not exist.
InvalidListFileDefinition β Invalid format in the list file.
- Returns:
Return either a list of connection pairs or a dictionary of lists which is collected by the specified option, source or sink.
- parseMatrix(fileName, tileName) dict[str, list[str]][source]ΒΆ
Parse the matrix CSV into a dictionary from destination to source.
- Parameters:
fileName (Path) β Directory of the matrix CSV file.
tileName (str) β Name of the tile needed to be parsed.
- Raises:
InvalidSwitchMatrixDefinition β Non matching matrix file content and tile name
- Returns:
Dictionary from destination to a list of sources.