Source code for pyvcad_attribute_resolver.conversion_entry
[docs]
class ConversionEntry:
"""A registered conversion between two attribute types.
Each entry represents a directed edge in the conversion graph, from a
source attribute to a target attribute. The ``converter_factory`` callable
produces a fresh ``AttributeConverterBase`` instance each time it is
invoked, supporting clone-safe, thread-safe parallel evaluation.
Attributes:
source: Input attribute name.
target: Output attribute name.
converter_factory: Zero-argument callable returning an
``AttributeConverterBase``.
name: Human-readable identifier for this conversion.
priority: Higher values are preferred when disambiguating
multiple equally-short paths.
tags: Context-filtering labels (e.g. ``"foaming_tpu"``).
required_inputs: Attribute names that must already be present on the
design before this conversion can be applied.
"""
def __init__(self, source, target, converter_factory,
name=None, priority=0, tags=None, required_inputs=None):
self.source = source
self.target = target
self.converter_factory = converter_factory
self.name = name or f"{source}_to_{target}"
self.priority = priority
self.tags = tags or []
self.required_inputs = list(required_inputs) if required_inputs else [source]
def __repr__(self):
return (f"ConversionEntry('{self.source}' -> '{self.target}', "
f"name='{self.name}', priority={self.priority}, "
f"required_inputs={self.required_inputs})")