XmlParser#

class pyedb.xml_parser.xml_parser.XmlParser(/, **data: Any)#

Bases: pydantic.BaseModel

Main parser for EDB XML configuration files.

This class provides methods to load, parse, and export XML configuration files used in EDB designs. It supports stackup definitions, import options, and net configurations.

Parameters:
stackupXmlStackup, optional

Stackup configuration object. The default is None.

import_optionsXmlImportOptions, optional

Import options configuration. The default is None.

netsdict, optional

Dictionary of net configurations. The default is None.

schema_versionstr, optional

Version of the XML schema. The default is None.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser.load_xml_file("config.xml")
>>> parser.to_xml_file("output.xml")

Overview#

load_xml_file

Load and parse an XML configuration file.

add_stackup

Add a stackup configuration to the parser.

to_xml

Convert the parser configuration to XML string.

to_xml_file

Write the parser configuration to an XML file.

to_dict

Convert the parser configuration to a dictionary.

stackup

import_options

nets

schema_version

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Import detail#

from pyedb.xml_parser.xml_parser import XmlParser

Attribute detail#

XmlParser.stackup: pyedb.xml_parser.xml_stackup.XmlStackup | None = None#
XmlParser.import_options: XmlImportOptions | None = None#
XmlParser.nets: dict | None = None#
XmlParser.schema_version: str | None = None#
XmlParser.model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Method detail#

XmlParser.add_stackup() pyedb.xml_parser.xml_stackup.XmlStackup#

Add a stackup configuration to the parser.

Returns:
XmlStackup

The newly created stackup object.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser()
>>> stackup = parser.add_stackup()
classmethod XmlParser.load_xml_file(path: str | pathlib.Path) XmlParser#

Load and parse an XML configuration file.

Parameters:
pathstr or pathlib.Path

Path to the XML file to load.

Returns:
XmlParser

The parsed XML configuration as an XmlParser instance.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser.load_xml_file("config.xml")
>>> print(parser.stackup)
XmlParser.to_xml(root_name: str = 'c:Control', pretty: bool = True) str#

Convert the parser configuration to XML string.

Parameters:
root_namestr, optional

Name of the root XML tag. The default is "c:Control".

prettybool, optional

Whether to format the XML output with indentation. The default is True.

Returns:
str

XML string representation of the configuration.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser()
>>> xml_string = parser.to_xml()
XmlParser.to_xml_file(file_path: str | pathlib.Path) str#

Write the parser configuration to an XML file.

Parameters:
file_pathstr or pathlib.Path

Path to the output XML file.

Returns:
str

Path to the written XML file.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser()
>>> output_path = parser.to_xml_file("output.xml")
XmlParser.to_dict() dict#

Convert the parser configuration to a dictionary.

Returns:
dict

Dictionary representation of the configuration containing stackup information.

Examples

>>> from pyedb.xml_parser.xml_parser import XmlParser
>>> parser = XmlParser()
>>> config_dict = parser.to_dict()