Parser
Methods for turning strings and lists into EDeA dataclasses.
- edea.kicad.parser.from_list(l_expr: list[str | QuotedStr | list[str | QuotedStr | SExprList]]) KicadExpr
Build a
KicadExpr
from a list.- Parameters:
l_expr – The KiCad S-expression list.
- Returns:
The corresponding
KicadExpr
instance if parsing is successful.- Raises:
ValueError –
If the parsing fails due to one of the following reasons:
No matching KiCad expression class is found for the tag name in the s-expression atom.
An exception occurs during the parsing attempt by a matching KiCad expression class.
- edea.kicad.parser.from_str_to_list(text: str) list[str | QuotedStr | list[str | QuotedStr | SExprList]]
Parses a KiCad expression string into a corresponding S-expression recursive list.
- Parameters:
text – The KiCad expression string to be parsed.
- Returns:
The parsed S-expression list representing the KiCad expression.
- Raises:
ValueError – If the parsing process results in a single string token instead of a complete S-expression.
- edea.kicad.parser.from_str(text: str) KicadExpr
Parses a KiCad expression string into a corresponding EDeA dataclass.
- Parameters:
text – The KiCad expression string to be parsed.
- Returns:
The parsed KiCad expression object.
- edea.kicad.parser.parse_schematic(text: str) Schematic
Parses a KiCad schematic file content into a
Schematic
.- Parameters:
text – The content of a KiCad schematic file.
- Returns:
A Schematic object representing the parsed schematic data.
- edea.kicad.parser.parse_pcb(text: str) Pcb
Parses a KiCad PCB file content into a
Pcb
.- Parameters:
text – The content of a KiCad PCB file.
- Returns:
A Pcb object representing the parsed PCB data.
- edea.kicad.parser.parse_design_rules(text: str) DesignRuleSet
Parses a KiCad design rules file content into a
DesignRuleSet
.- Parameters:
text – The content of a KiCad design rules file.
- Returns:
A DesignRules object representing the parsed design rules.
- edea.kicad.parser.load_schematic(path: Path | str) Schematic
Loads a KiCad schematic file and parses its content into a
Schematic
.- Parameters:
path – The path to the KiCad schematic file.
- Returns:
A Schematic object representing the loaded file.
- edea.kicad.parser.load_pcb(path: Path | str) Pcb
Loads a KiCad PCB file and parses its content into a
Pcb
.- Parameters:
path – The path to the KiCad PCB file.
- Returns:
A Pcb object representing the loaded file.
- edea.kicad.parser.load_design_rules(path: Path | str) DesignRuleSet
Loads a KiCad design rules file and parses its content into a
DesignRuleSet
.- Parameters:
path – The path to the KiCad design rules file.
- Returns:
A DesignRules object representing the loaded file.