XmlGeneric#

class pyedb.misc.siw_feature_config.emc.xml_generic.XmlGeneric(element)#

Generic XML handler for EMC configuration.

This class provides a generic interface for creating, reading, and writing XML configurations. It supports nested elements and automatic attribute mapping.

Parameters:
elementxml.etree.ElementTree.Element or None

XML element to initialize from.

Attributes:
DEBUGbool

Debug flag for additional logging.

CLS_MAPPINGdict

Mapping of element types to their corresponding classes.

Examples

>>> from pyedb.misc.siw_feature_config.emc.xml_generic import XmlGeneric
>>> element = None
>>> xml_obj = XmlGeneric(element)
>>> kwargs = {"name": "test", "value": "123"}
>>> xml_obj.create(kwargs)

Overview#

add_sub_element

Add a sub-element to the XML structure.

create

Create XML object from keyword arguments.

write_xml

Write object to XML element tree.

write_dict

Write object to dictionary format.

read_dict

Read object from dictionary format.

Import detail#

from pyedb.misc.siw_feature_config.emc.xml_generic import XmlGeneric

Attribute detail#

XmlGeneric.DEBUG: bool = False#
XmlGeneric.CLS_MAPPING: dict#
XmlGeneric.sub_elements: list = []#

Method detail#

XmlGeneric.add_sub_element(kwargs: dict, elem_type: str) None#

Add a sub-element to the XML structure.

Parameters:
kwargsdict

Dictionary of keyword arguments for the sub-element.

elem_typestr

Type of the element to add.

Examples

>>> xml_obj = XmlGeneric(None)
>>> kwargs = {"name": "component1", "value": "100"}
>>> xml_obj.add_sub_element(kwargs, "Component")
XmlGeneric.create(kwargs: dict)#

Create XML object from keyword arguments.

Parameters:
kwargsdict

Dictionary of keyword arguments to populate the object.

Returns:
XmlGeneric

Self reference for method chaining.

Examples

>>> xml_obj = XmlGeneric(None)
>>> kwargs = {"name": "net1", "impedance": "50"}
>>> xml_obj.create(kwargs)
XmlGeneric.write_xml(parent)#

Write object to XML element tree.

Parameters:
parentxml.etree.ElementTree.Element

Parent XML element to write to.

Returns:
xml.etree.ElementTree.Element

Parent element with added content.

Examples

>>> import xml.etree.ElementTree as ET
>>> parent = ET.Element("Root")
>>> xml_obj = XmlGeneric(None)
>>> xml_obj.write_xml(parent)
XmlGeneric.write_dict(parent: dict) None#

Write object to dictionary format.

Parameters:
parentdict

Parent dictionary to write to.

Examples

>>> xml_obj = XmlGeneric(None)
>>> output = {}
>>> xml_obj.write_dict(output)
>>> print(output)
XmlGeneric.read_dict(data: dict) None#

Read object from dictionary format.

Parameters:
datadict

Dictionary containing configuration data.

Examples

>>> xml_obj = XmlGeneric(None)
>>> data = {"sub_elements": [{"Component": {"name": "C1", "value": "10uF"}}]}
>>> xml_obj.read_dict(data)