maya.utils.converter.parsing ============================ .. py:module:: maya.utils.converter.parsing .. autoapi-nested-parse:: AST parsing utilities for tik.maya code analysis. This module handles parsing of Python source code using the AST module, providing utilities for analyzing tik.maya expressions without relying on tik.maya internals. Classes ------- .. autoapisummary:: maya.utils.converter.parsing.ParsedExpression maya.utils.converter.parsing.TikMayaASTVisitor Functions --------- .. autoapisummary:: maya.utils.converter.parsing.get_node_source maya.utils.converter.parsing.parse_source maya.utils.converter.parsing.unparse_node Module Contents --------------- .. py:class:: ParsedExpression Represents a parsed tik.maya expression with context. .. py:attribute:: col_offset :type: int .. py:attribute:: end_col_offset :type: Optional[int] .. py:attribute:: end_line_number :type: Optional[int] .. py:attribute:: line_number :type: int .. py:attribute:: node :type: ast.AST .. py:attribute:: source_segment :type: str .. py:class:: TikMayaASTVisitor(source_lines: List[str]) Bases: :py:obj:`ast.NodeVisitor` AST visitor that identifies tik.maya patterns in source code. This visitor recognizes: - Node creation patterns (Transform.create(), Mesh.create(), etc.) - Attribute access patterns (node["attr"], node.property) - Attribute assignment patterns (node["attr"].set(), node.property = value) - Connection patterns (plug.connect(), plug >> other_plug) - Method call patterns on tik.maya objects .. py:method:: get_source_segment(start_line: int, start_col: int, end_line: Optional[int], end_col: Optional[int]) -> str Extract source code segment from line/column positions. Args: start_line: 1-based starting line number. start_col: 0-based starting column. end_line: 1-based ending line number (optional). end_col: 0-based ending column (optional). Returns: The source code segment as a string. .. py:method:: visit_Import(node: ast.Import) -> Any Track import statements for tik modules. .. py:method:: visit_ImportFrom(node: ast.ImportFrom) -> Any Track from ... import statements for tik modules. .. py:attribute:: TIK_IMPORT_PATTERNS .. py:attribute:: TIK_TYPES .. py:attribute:: found_expressions :type: List[ParsedExpression] :value: [] .. py:attribute:: source_lines .. py:attribute:: tik_imports :type: Dict[str, str] .. py:attribute:: tik_names :type: Dict[str, str] .. py:function:: get_node_source(node: ast.AST, source_lines: List[str]) -> str Extract source code for an AST node. Args: node: AST node with line/column info. source_lines: List of source code lines. Returns: The source code corresponding to the node. .. py:function:: parse_source(source_code: str) -> Tuple[ast.Module, List[str]] Parse Python source code into AST and lines. Args: source_code: Python source code string. Returns: Tuple of (AST module, list of source lines). Raises: SyntaxError: If the source code has syntax errors. .. py:function:: unparse_node(node: ast.AST) -> str Convert an AST node back to source code. Args: node: AST node to unparse. Returns: Python source code string.