### Combining Tools for AST Refactoring with NodeTourist and predicates Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md This example demonstrates how to combine astToolkit.NodeTourist with predicate functions (like those in astToolkit.Be) to selectively process specific types of AST nodes during a traversal. ```python import astToolFactory.astToolkit as astToolkit import ast # Define a custom action to be performed on FunctionDef nodes def factor_function_body(node): print(f"Factoring body of function: {node.name}") # Example: Extract statements from the body for stmt in node.body: print(f" - Statement: {type(stmt).__name__}") # Create a NodeTourist instance that targets FunctionDef nodes and applies the action tourist = astToolFactory.NodeTourist(astToolkit.Be.FunctionDef, factor_function_body) # Example AST structure # tree = ast.parse("def my_func(x):\n y = x + 1\n return y") # tourist.visit(tree) ``` -------------------------------- ### Refactoring Call Node Attributes with NodeChanger, Grab, and Refactor Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md This example shows how to use astToolkit.NodeChanger in conjunction with astToolkit.Grab and astToolkit.Refactor to precisely modify attributes of ast.Call nodes during transformation. ```python import astToolFactory.astToolkit as astToolkit import ast # Define a refactoring strategy for the 'func' attribute of a Call node def systematically_refactor_func(node): print(f"Refactoring function attribute: {ast.dump(node)}") # Example: Replace a specific function name with another if isinstance(node, ast.Name) and node.id == 'old_func': return ast.Name(id='new_func', ctx=node.ctx) return node # Create a NodeChanger that targets Call nodes # It grabs the 'func' attribute and applies the refactoring strategy changer = astToolFactory.NodeChanger( astToolkit.Be.Call, astToolkit.Grab.funcAttribute(astToolkit.Refactor.systematically(systematically_refactor_func)) ) # Example AST structure # tree = ast.parse("old_func(1, 2)") # new_tree = changer.visit(tree) # print(ast.dump(new_tree)) ``` -------------------------------- ### Get Elements for Make Tool (getElementsMake) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves data elements needed to generate the Make node constructor class. ```APIDOC ## Get Elements for Make Tool (getElementsMake) ### Description Retrieves data elements needed to generate the Make node constructor class. ### Method `getElementsMake` ### Parameters #### Path Parameters None #### Query Parameters - **toolName** (str) - Required - The name of the tool (e.g., "Make"). #### Request Body None ### Request Example ```python from astToolFactory.datacenter import getElementsMake # Get Make tool generation data elements = getElementsMake("Make") ``` ### Response #### Success Response (200) Returns a list of tuples containing constructor specifications for the Make tool. #### Response Example ```python # Returns list of tuples with constructor specifications: # [(ClassDefIdentifier, listFunctionDef_args, kwarg_annotationIdentifier, # defaults, classAs_astAttribute, overloadDefinition, listCall_keyword, # guardVersion, versionMinorMinimum), ...] for class_id, args, kwarg_id, defaults, *rest in elements[:5]: print(f"Make.{class_id}({len(args)} args)") ``` ``` -------------------------------- ### Get Elements for Make Tool with getElementsMake Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves data elements for generating the Make node constructor class. The function returns tuples specifying constructor arguments, annotations, defaults, and version guards. ```python from astToolFactory.datacenter import getElementsMake # Get Make tool generation data elements = getElementsMake("Make") # Returns list of tuples with constructor specifications: # [(ClassDefIdentifier, listFunctionDef_args, kwarg_annotationIdentifier, # defaults, classAs_astAttribute, overloadDefinition, listCall_keyword, # guardVersion, versionMinorMinimum), ...] for class_id, args, kwarg_id, defaults, *rest in elements[:5]: print(f"Make.{class_id}({len(args)} args)") ``` -------------------------------- ### Get Elements for Be Tool (getElementsBe) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves data elements needed to generate the Be type-checking class. ```APIDOC ## Get Elements for Be Tool (getElementsBe) ### Description Retrieves data elements needed to generate the Be type-checking class. ### Method `getElementsBe` ### Parameters #### Path Parameters None #### Query Parameters - **toolName** (str) - Required - The name of the tool (e.g., "Be"). #### Request Body None ### Request Example ```python from astToolFactory.datacenter import getElementsBe # Get Be tool generation data elements = getElementsBe("Be") ``` ### Response #### Success Response (200) Returns a list of tuples containing data elements for the Be tool. #### Response Example ```python # Returns list of tuples: # [(ClassDefIdentifier, versionMinorMinimum, classAs_astAttribute, listTupleAttributes), ...] # Example: # ('FunctionDef', 10, ast.Attribute('ast.FunctionDef'), [('name', str_expr), ...]) for class_id, version_min, ast_attr, attrs in elements: print(f"{class_id}: v3.{version_min}+, attrs={len(attrs)}") ``` ``` -------------------------------- ### Get Elements for Be Tool with getElementsBe Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves data elements needed to generate the Be type-checking class. The function returns a list of tuples containing class identifiers, minimum versions, AST attribute representations, and attribute lists. ```python from astToolFactory.datacenter import getElementsBe # Get Be tool generation data elements = getElementsBe("Be") # Returns list of tuples: # [(ClassDefIdentifier, versionMinorMinimum, classAs_astAttribute, listTupleAttributes), ...] # Example: ('FunctionDef', 10, ast.Attribute('ast.FunctionDef'), [('name', str_expr), ...]) for class_id, version_min, ast_attr, attrs in elements: print(f"{class_id}: v3.{version_min}+, attrs={len(attrs)}") ``` -------------------------------- ### Creating New AST Nodes with astToolkit.Make Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md The astToolkit.Make module provides factory functions for constructing new AST nodes from raw materials. It supports the creation of various AST constructs like FunctionDef, Call, and Name nodes. ```python import astToolFactory.astToolkit as astToolkit # Example usage: # new_function_node = astToolkit.Make.FunctionDef(name='my_new_func', args=[], body=[]) # new_call_node = astToolkit.Make.Call(func=astToolkit.Make.Name('print'), args=['"Hello"']) # new_name_node = astToolkit.Make.Name('my_variable') ``` -------------------------------- ### Traversing AST Trees with astToolkit.NodeTourist Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md astToolkit.NodeTourist is a visitor pattern implementation for traversing AST trees. It allows for discovering specific AST nodes like FunctionDef, ClassDef, Call, and Name, and applying actions to them. ```python import astToolFactory.astToolkit as astToolkit # Example usage: # class MyVisitor(astToolkit.NodeTourist): # def visit_FunctionDef(self, node): # print(f"Found function: {node.name}") # self.generic_visit(node) # tree = ast.parse("def greet():\n print('hello')") # visitor = MyVisitor() # visitor.visit(tree) ``` -------------------------------- ### Configure AST Manufacturing Settings (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Defines the configuration dataclass for controlling the AST manufacturing process. Allows customization of package identifier, output path, Python version support, and inclusion of deprecated nodes. ```python from astToolFactory._theSSOT import ManufacturedPackageSettings from pathlib import Path # Create custom manufacturing settings custom_settings = ManufacturedPackageSettings( identifierPackage="myASTTools", pathPackage=Path("/path/to/output"), pythonMinimumVersionMinor=12, # Target Python 3.12+ versionMinorMaximum=14, # Up to Python 3.14 includeDeprecated=False, # Exclude deprecated AST nodes pathFilenameDataframeAST=Path("datacenter/_dataframeAST.pkl"), ) ``` -------------------------------- ### Generate Make Tool for Node Construction (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates the 'Make' class, providing node constructor methods with proper parameter types and default values. Facilitates the creation of AST nodes programmatically. ```python from astToolFactory.factory import makeToolMake # Generate the Make class with node constructors makeToolMake("Make") # Generated code enables usage like: # # Create a simple function definition # func = Make.FunctionDef( # "calculate", # Make.arguments(list_arg=[Make.arg("x", Make.Name("int"))]), # body=[Make.Return(Make.BinOp(Make.Name("x"), Make.Mult(), Make.Constant(2)))], # returns=Make.Name("int") # ) # # # Create a class definition # cls = Make.ClassDef( # "Vehicle", # bases=[Make.Name("ABC")], # ) ``` -------------------------------- ### Inspecting AST Node Attributes with astToolkit.DOT Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md The astToolkit.DOT module allows for the inspection and extraction of attributes from AST nodes. It provides methods to access names, arguments, and bodies of various AST constructs. ```python import astToolFactory.astToolkit as astToolkit # Example usage: # Assuming 'node' is an AST node representing a function call # function_name = astToolkit.DOT.name(node) # arguments = astToolkit.DOT.args(node) # body_statements = astToolkit.DOT.body(node) ``` -------------------------------- ### Extracting and Modifying AST Node Attributes with astToolkit.Grab Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md The astToolkit.Grab module facilitates the extraction of specific attributes from AST nodes for subsequent refactoring. It enables targeted modification of node components like names or arguments. ```python import astToolFactory.astToolkit as astToolkit # Example usage: # Assuming 'func_node' is an AST node for a function definition # original_name = astToolkit.Grab.FunctionDef.name(func_node) # astToolkit.Grab.FunctionDef.name(func_node, "new_function_name") # To refactor the name ``` -------------------------------- ### Identifying AST Node Types with astToolkit.Be Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md The astToolkit.Be module provides predicates for checking the type of manufactured AST nodes. It helps determine if an AST node represents a specific construct like a FunctionDef or ClassDef. ```python import astToolFactory.astToolkit as astToolkit # Example usage: # Assuming 'node' is an AST node # if astToolkit.Be.FunctionDef(node): # print("This is a Function Definition") # elif astToolkit.Be.ClassDef(node): # print("This is a Class Definition") ``` -------------------------------- ### CPython ASDL Match Args Extraction Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Extracts `__match_args__` tuples from Python.asdl files across versions. ```APIDOC ## CPython ASDL Match Args Extraction ### Description Extracts `__match_args__` tuples from Python.asdl files across versions. ### Method `getDictionary_match_args` ### Parameters None ### Request Example ```python from astToolFactory.cpython import getDictionary_match_args # Get match_args for all AST classes across Python versions match_args = getDictionary_match_args() ``` ### Response #### Success Response (200) Returns a dictionary mapping AST class and version to its `__match_args__` tuple. #### Response Example ```python # Returns dict keyed by (ClassDefIdentifier, versionMinor, deprecated) # Example access: print(match_args[('FunctionDef', 14, False)]) # ('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params') print(match_args[('Call', 13, False)]) # ('func', 'args', 'keywords') # Check version differences for version in range(10, 15): key = ('Match', version, False) if key in match_args: print(f"Python 3.{version}: Match args = {match_args[key]}") ``` ``` -------------------------------- ### Writing Generated Modules Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Writes AST modules to disk with proper formatting and type ignores. ```APIDOC ## Writing Generated Modules ### Description Writes AST modules to disk with proper formatting and type ignores. ### Method `writeModule`, `writeClass` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body For `writeModule`: - **moduleAst** (ast.Module) - Required - The AST module node to write. - **moduleName** (str) - Required - The name of the module file (without .py extension). For `writeClass`: - **className** (str) - Required - The name of the class to generate. - **list4ClassDefBody** (list[ast.AST]) - Optional - AST nodes for the class body. - **list4ModuleBody** (list[ast.AST]) - Optional - AST nodes for the module body (e.g., imports). - **identifierModulePrefix** (str) - Optional - Prefix for the generated module file name. ### Request Example ```python from astToolFactory.factory import writeModule, writeClass from astToolkit import Make # Create an AST module module = Make.Module([ Make.ImportFrom("typing", [Make.alias("Any")]), Make.FunctionDef("helper", body=[Make.Return(Make.Constant(42))]) ]) # Write to file with automatic formatting writeModule(module, "_generated_module") # Write a class definition with its module writeClass( "MyTool", list4ClassDefBody=[Make.FunctionDef("method", body=[Make.Pass()])], list4ModuleBody=[Make.Import("ast", None)], identifierModulePrefix="_tool" ) ``` ### Response #### Success Response (200) Creates Python files on disk with the generated code. #### Response Example ```python # Creates: _generated_module.py with formatted Python code # Creates: _toolMyTool.py ``` ``` -------------------------------- ### Extract CPython ASDL Match Args with getDictionary_match_args Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Extracts `__match_args__` tuples from Python.asdl files across different versions. The function returns a dictionary keyed by class definition identifier, version, and deprecation status. ```python from astToolFactory.cpython import getDictionary_match_args # Get match_args for all AST classes across Python versions match_args = getDictionary_match_args() # Returns dict keyed by (ClassDefIdentifier, versionMinor, deprecated) # Example access: print(match_args[('FunctionDef', 14, False)]) # ('name', 'args', 'body', 'decorator_list', 'returns', 'type_comment', 'type_params') print(match_args[('Call', 13, False)]) # ('func', 'args', 'keywords') # Check version differences for version in range(10, 15): key = ('Match', version, False) if key in match_args: print(f"Python 3.{version}: Match args = {match_args[key]}") ``` -------------------------------- ### Create Version Guards with _makeSimpleGuardVersion Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Creates Python version guards for conditional code generation. This utility function wraps a statement or a list of statements within a version check, ensuring compatibility across Python versions. ```python from astToolFactory.factory import _makeSimpleGuardVersion from astToolkit import Make # Create a version-guarded statement for Python 3.12+ guarded_stmt = _makeSimpleGuardVersion( [Make.FunctionDef("new_feature", body=[Make.Pass()])], versionMinorMinimum=12 ) # Generated code equivalent: # if sys.version_info >= (3, 12): # def new_feature(): # pass ``` -------------------------------- ### Load Pandas DataFrame from Pickle File (Python) Source: https://github.com/hunterhogan/asttoolfactory/blob/main/astToolFactory/datacenter/dataframeViewer.ipynb This snippet demonstrates how to load a Pandas DataFrame from a pickle file. It imports necessary libraries and reads the dataframe using a predefined path from settings. The primary dependency is the pandas library and the astToolFactory.settingsManufacturing module. ```python from astToolFactory import settingsManufacturing import pandas dataframe: pandas.DataFrame = pandas.read_pickle(settingsManufacturing.pathFilenameDataframeAST) ``` -------------------------------- ### Generate Grab Tool for Attribute Modification (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates the 'Grab' class, providing attribute modification methods that apply transformations to specific node attributes. Supports single modifications, chained transformations, and index-based updates. ```python from astToolFactory.factory import makeToolGrab # Generate the Grab class with attribute modifiers makeToolGrab("Grab") # Generated code enables usage like: # # Modify a function's name # rename_action = Grab.nameAttribute(lambda name: name.upper()) # modified_node = rename_action(function_def_node) # # # Chain multiple modifications # transform = Grab.andDoAllOf([ # Grab.nameAttribute(lambda n: f"test_{n}"), # Grab.bodyAttribute(lambda body: body + [Make.Pass()]) # ]) # modified = transform(node) # # # Modify at specific index # update_first_arg = Grab.index(0, lambda arg: Make.arg("self")) ``` -------------------------------- ### Version Guard Generation Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Creates Python version guards for conditional code generation. ```APIDOC ## Version Guard Generation ### Description Creates Python version guards for conditional code generation. ### Method `_makeSimpleGuardVersion` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **statements** (list[ast.AST]) - Required - A list of AST statements to guard. - **versionMinorMinimum** (int) - Required - The minimum Python minor version (e.g., 12 for 3.12). ### Request Example ```python from astToolFactory.factory import _makeSimpleGuardVersion from astToolkit import Make # Create a version-guarded statement for Python 3.12+ guarded_stmt = _makeSimpleGuardVersion( [Make.FunctionDef("new_feature", body=[Make.Pass()])], versionMinorMinimum=12 ) ``` ### Response #### Success Response (200) Returns an AST node representing the version-guarded code. #### Response Example ```python # Generated code equivalent: # if sys.version_info >= (3, 12): # def new_feature(): # pass ``` ``` -------------------------------- ### Manufacture AST Tools for astToolkit (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Orchestrates the generation of all AST tool modules, including type checking, attribute access, modification, and construction. This is the primary entry point for the factory. ```python from astToolFactory.factory import manufactureTools from astToolFactory import settingsManufacturing # Generate all tool classes for astToolkitmanufactureTools(settingsManufacturing) # This produces the following modules: # - _toolBe.py: Type checking predicates (Be.FunctionDef, Be.Call, etc.) # - _toolDOT.py: Attribute accessors (DOT.name, DOT.args, etc.) # - _toolGrab.py: Attribute modifiers (Grab.nameAttribute, etc.) # - _toolMake.py: Node constructors (Make.FunctionDef, Make.Call, etc.) # - _theSSOT.py: Single Source of Truth settings # - _theTypes.py: Type aliases and TypeVars ``` -------------------------------- ### Parse Python Source Code to AST Dump (Python) Source: https://github.com/hunterhogan/asttoolfactory/blob/main/astToolFactory/datacenter/dataframeViewer.ipynb This snippet demonstrates parsing Python source code into an Abstract Syntax Tree (AST) and then dumping it in a structured format. It utilizes the ast and astToolkit libraries. The input is a string containing Python source code, and the output is a formatted string representation of the AST. ```python # from astToolkit import dump # import ast # source=''' # ''' # print(dump(ast.parse(source, type_comments=True), indent=None, show_empty=False, annotate_fields=False)) ``` -------------------------------- ### Transforming AST Trees with astToolkit.NodeChanger Source: https://github.com/hunterhogan/asttoolfactory/blob/main/README.md astToolkit.NodeChanger is a transformer pattern implementation for refactoring AST trees with precision. It allows for targeted replacements and modifications of AST nodes while preserving other parts of the tree. ```python import astToolFactory.astToolkit as astToolkit import ast # Example usage: # class MyTransformer(astToolkit.NodeChanger): # def visit_Add(self, node): # # Replace ast.Add with ast.Sub # return ast.Sub(left=node.left, right=node.right) # tree = ast.parse("a = 1 + 2") # transformer = MyTransformer() # new_tree = transformer.visit(tree) # print(ast.dump(new_tree)) ``` -------------------------------- ### Generate Be Tool for Type Checking (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates the 'Be' class, providing type-checking predicate methods with TypeIs annotations for compile-time type narrowing. Enables safe AST node type checking. ```python from astToolFactory.factory import makeToolBe # Generate the Be class with type predicates makeToolBe("Be") # Generated code enables usage like: # if Be.FunctionDef(node): # print(node.name) # Type-safe access - compiler knows node is ast.FunctionDef # # if Be.Call(node) and Be.Name(node.func): # print(node.func.id) # Type-safe nested access # # # Using predicates in visitor patterns: # NodeTourist(Be.Return, Then.extractIt(DOT.value)).visit(tree) ``` -------------------------------- ### Write Generated Modules and Classes with writeModule and writeClass Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Writes AST modules and classes to disk with proper formatting and type ignores. These functions handle the serialization of AST structures into Python files, including imports and class definitions. ```python from astToolFactory.factory import writeModule, writeClass from astToolkit import Make # Create an AST module module = Make.Module([ Make.ImportFrom("typing", [Make.alias("Any")]), Make.FunctionDef("helper", body=[Make.Return(Make.Constant(42))]) ]) # Write to file with automatic formatting writeModule(module, "_generated_module") # Creates: _generated_module.py with formatted Python code # Write a class definition with its module writeClass( "MyTool", list4ClassDefBody=[Make.FunctionDef("method", body=[Make.Pass()])], list4ModuleBody=[Make.Import("ast", None)], identifierModulePrefix="_tool" ) # Creates: _toolMyTool.py ``` -------------------------------- ### Unparse AST to Python Code (Python) Source: https://github.com/hunterhogan/asttoolfactory/blob/main/astToolFactory/datacenter/dataframeViewer.ipynb This snippet shows how to convert an Abstract Syntax Tree (AST) back into Python source code. It uses the ast and astToolkit libraries, specifically the Make.Module function and ast.unparse. The input is a string that is evaluated to create AST nodes, which are then unparsed into a Python code string. ```python # from astToolkit import Make # import ast # source=''' # ''' # print(ast.unparse(Make.Module([eval(source)]))) ``` -------------------------------- ### Generate DOT Tool for Attribute Access (Python) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates the 'DOT' class, providing read-only attribute accessor methods with proper return type annotations. Handles version differences automatically for AST attributes. ```python from astToolFactory.factory import makeToolDOT # Generate the DOT class with attribute accessors makeToolDOT("DOT") # Generated code enables usage like: # function_name = DOT.name(function_def_node) # Returns str # arguments = DOT.args(function_def_node) # Returns ast.arguments # body_stmts = DOT.body(function_def_node) # Returns list[ast.stmt] # # # DOT handles version differences automatically: # type_params = DOT.type_params(node) # Only available in Python 3.12+ ``` -------------------------------- ### Data Server API (getDataframe) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves filtered AST metadata from the pre-computed DataFrame. Allows filtering by version and inclusion of deprecated nodes. ```APIDOC ## Data Server API (getDataframe) ### Description Retrieves filtered AST metadata from the pre-computed DataFrame. ### Method `getDataframe` ### Parameters #### Path Parameters None #### Query Parameters - **versionMinorMaximum** (int) - Optional - Include up to this Python minor version. - **includeDeprecated** (bool) - Optional - Whether to include deprecated nodes. - **modifyVersionMinorMinimum** (bool) - Optional - Modifies the version minor minimum. - **indexColumns** (list[str]) - Optional - Columns to index the DataFrame by. #### Request Body None ### Request Example ```python from astToolFactory.datacenter import getDataframe # Get all AST data filtered by version df = getDataframe( versionMinorMaximum=14, # Include up to Python 3.14 includeDeprecated=False, # Exclude deprecated nodes modifyVersionMinorMinimum=True ) # Get data indexed by specific columns df_indexed = getDataframe("ClassDefIdentifier", "attribute") ``` ### Response #### Success Response (200) Returns a pandas DataFrame containing AST metadata. #### Response Example ```python # Access specific elements print(df.columns.tolist()) # ['ClassDefIdentifier', 'attribute', 'attributeKind', 'attributeType', # 'versionMinorPythonInterpreter', 'deprecated', 'classAs_astAttribute', ...] ``` ``` -------------------------------- ### Generate Type Aliases with make_astTypes Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates type aliases for AST node categories used across the toolkit. This function creates a module containing type definitions for various AST node attributes and values. ```python from astToolFactory.factory import make_astTypes # Generate type aliases module make_astTypes("_theTypes") # Generated types include: # type ConstantValueType = bool | bytes | complex | EllipsisType | float | int | None | range | str # type identifierDotAttribute = str # type astASTattributes = ast.AST | ConstantValueType | list[ast.AST] | list[ast.AST | None] | list[str] # # class ast_attributes(TypedDict, total=False): # lineno: int # col_offset: int # end_lineno: int | None # end_col_offset: int | None ``` -------------------------------- ### Retrieve Filtered AST Metadata with getDataframe Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Retrieves filtered AST metadata from a pre-computed DataFrame. This function allows fetching all AST data filtered by version or data indexed by specific columns. ```python from astToolFactory.datacenter import getDataframe # Get all AST data filtered by version df = getDataframe( versionMinorMaximum=14, # Include up to Python 3.14 includeDeprecated=False, # Exclude deprecated nodes modifyVersionMinorMinimum=True ) # Get data indexed by specific columns df_indexed = getDataframe("ClassDefIdentifier", "attribute") # Access specific elements print(df.columns.tolist()) # ['ClassDefIdentifier', 'attribute', 'attributeKind', 'attributeType', # 'versionMinorPythonInterpreter', 'deprecated', 'classAs_astAttribute', ...] ``` -------------------------------- ### Type Alias Generator (make_astTypes) Source: https://context7.com/hunterhogan/asttoolfactory/llms.txt Generates type aliases for AST node categories used across the toolkit. These aliases help in defining types for various AST node attributes. ```APIDOC ## Type Alias Generator (make_astTypes) ### Description Generates type aliases for AST node categories used across the toolkit. ### Method `make_astTypes` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from astToolFactory.factory import make_astTypes # Generate type aliases module make_astTypes("_theTypes") ``` ### Response #### Success Response (200) Generates type alias definitions in a module. #### Response Example ```python # Generated types include: type ConstantValueType = bool | bytes | complex | EllipsisType | float | int | None | range | str type identifierDotAttribute = str type astASTattributes = ast.AST | ConstantValueType | list[ast.AST] | list[ast.AST | None] | list[str] class ast_attributes(TypedDict, total=False): lineno: int col_offset: int end_lineno: int | None end_col_offset: int | None ``` ``` -------------------------------- ### Save Pandas DataFrame to Pickle File (Python) Source: https://github.com/hunterhogan/asttoolfactory/blob/main/astToolFactory/datacenter/dataframeViewer.ipynb This is a commented-out snippet showing how to save a Pandas DataFrame to a pickle file. It would typically be used to persist data. The function relies on the pandas library and a path defined in settings. ```python # dataframe.to_pickle(settingsManufacturing.pathFilenameDataframeAST) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.