pylasu.transformation package
Submodules
pylasu.transformation.generic_nodes module
pylasu.transformation.transformation module
- class pylasu.transformation.transformation.ASTTransformer(issues: List[Issue] = None, allow_generic_node: bool = True)[source]
Bases:
object
- allow_generic_node: bool = True
- factories: Dict[type, NodeFactory]
Factories that map from source tree node to target tree node.
- get_node_factory(node_type: Type[Source]) NodeFactory[Source, Target] | None [source]
- known_classes: Dict[str, Set[type]]
- make_nodes(factory: NodeFactory[Source, Target], source: Source) List[Node] [source]
- register_node_factory(source: Type[Source], factory: Callable[[Source, ASTTransformer, NodeFactory[Source, Output]], List[Output]] | Callable[[Source, ASTTransformer, NodeFactory[Source, Output]], Output] | Type[Target]) NodeFactory[Source, Target] [source]
- set_child(child_node_factory: ChildNodeFactory, source: Any, node: Node, pd: PropertyDescription)[source]
- class pylasu.transformation.transformation.ChildNodeFactory(name: str, get: Callable[[Source], Any | None], setter: Callable[[Target, Child | None], NoneType])[source]
Bases:
Generic
[Source
,Target
,Child
]- get: Callable[[Source], Any | None]
- name: str
- setter: Callable[[Target, Child | None], None]
- class pylasu.transformation.transformation.NodeFactory(constructor: Callable[[~Source, ForwardRef('ASTTransformer'), ForwardRef('NodeFactory[Source, Output]')], List[~Output]], children: Dict[str, ForwardRef('ChildNodeFactory[Source, Any, Any]')] = <factory>, finalizer: Callable[[~Source], NoneType] = <function NodeFactory.<lambda> at 0x7f7902b18400>)[source]
Bases:
Generic
[Source
,Output
]- children: Dict[str, ChildNodeFactory[Source, Any, Any]]
- constructor: Callable[[Source, ASTTransformer, NodeFactory[Source, Output]], List[Output]]
- finalizer()
- with_child(setter: Callable[[Target, Child | None], None] | PropertyRef, getter: Callable[[Source], Any | None] | PropertyRef, name: str | None = None, target_type: type | None = None) NodeFactory[Source, Output] [source]
- pylasu.transformation.transformation.ast_transformer(node_class: Type[Node], transformer: ASTTransformer, method_name: str = None)[source]
Decorator to register a function as an AST transformer