### Generate Examples Script Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Commands to clone the repository and generate example visualizations. ```sh git clone repourl cd intorepodirectory ./generate_examples.sh ``` -------------------------------- ### Installation Commands Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Commands to install py2cfg via pip or from source. ```sh pip3 install py2cfg --user ``` ```sh git clone cd intoprojectdirectory pip3 install . --user # or to hack on this project: pip3 install --editable . --user ``` -------------------------------- ### Install py2cfg Source: https://context7.com/classroomcode/py2cfg/llms.txt Install py2cfg using pip. ```bash pip3 install py2cfg --user ``` -------------------------------- ### Start the py2cfg server Source: https://context7.com/classroomcode/py2cfg/llms.txt Start the py2cfg JSON-RPC server, specifying the host, port, and directory to monitor. ```bash python3 -m py2cfg.server localhost 5000 --directory ./myproject ``` -------------------------------- ### Fibonacci Sequence Example Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md A sample Python script generating a Fibonacci sequence used for CFG demonstration. ```py # fib.py def fib(): a, b = 0, 1 while True: yield a a, b = b, a + b fib_gen = fib() for _ in range(10): next(fib_gen) ``` -------------------------------- ### Sorting Algorithms Example Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md A class containing merge sort and insertion sort implementations for CFG analysis. ```py class Sort: def merge(self, l, r): i = 0 j = 0 arr = [] size = len(l) + len(r) for k in range(0, size): lSentinel = i == len(l) rSentinel = j == len(r) if i == len(l): arr.append(r[j]) j += 1 elif j == len(r): arr.append(l[i]) i += 1 elif l[i] <= r[j]: arr.append(l[i]) i += 1 else: arr.append(r[j]) j += 1 return arr def merge_sort(self, src): n = len(src) / 2 l = src[0:n] r = src[n:] if len(l) > 1: l = self.merge_sort(l) if len(r) > 1: r = self.merge_sort(r) src = self.merge(l, r) return src def insertion_sort(self, src): j = 1 for j in range(1, len(src)): i = j - 1 key = src[j] while i >= 0 and src[i] >= key: src[i + 1] = src[i] i = i - 1 src[i + 1] = key return src ``` -------------------------------- ### Run directly from repository Source: https://context7.com/classroomcode/py2cfg/llms.txt Run py2cfg directly from the repository without installing it, useful for development or testing. ```bash python3 py2cfg/_runner.py ./examples/fib.py --outfile fib_cfg --format svg ``` -------------------------------- ### CFGBuilder Initialization Options Source: https://context7.com/classroomcode/py2cfg/llms.txt Configure the CFGBuilder with options like 'short' mode for cleaner visualizations. ```APIDOC ## CFGBuilder Initialization Options ### Description Configure the CFGBuilder with options like 'short' mode for cleaner visualizations. When `short=True`, strings longer than 20 characters are truncated with ellipsis for cleaner graphs. ### Method POST ### Endpoint /api/cfg/initialize ### Parameters #### Query Parameters - **short** (boolean) - Optional - If true, truncates long strings in the visualization. Defaults to false. ### Request Example ```python from py2cfg import CFGBuilder # Without short mode - full strings displayed builder_full = CFGBuilder(short=False) cfg_full = builder_full.build_from_file('full', './mycode.py') # With short mode - strings truncated at 20 chars builder_short = CFGBuilder(short=True) cfg_short = builder_short.build_from_file('short', './mycode.py') # Generate both for comparison cfg_full.build_visual('output_full', format='svg', show=False) cfg_short.build_visual('output_short', format='svg', show=False) ``` ### Response #### Success Response (200) - **message** (string) - Confirmation that the builder was initialized with the specified options. #### Response Example ```json { "message": "CFGBuilder initialized with short mode enabled." } ``` ``` -------------------------------- ### Run via Wrapper Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Executing the runner script directly from the repository. ```bash cd intoreporootdir python3 py2cfg/_runner.py --outfile ``` -------------------------------- ### Interactive CFG debugging and visualization Source: https://context7.com/classroomcode/py2cfg/llms.txt Demonstrates how to outline specific blocks and highlight executed lines during a debugging session, followed by generating an interactive visualization. ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('debug', './example.py') blocks = list(cfg.own_blocks()) # Outline the block at current debugger line current_line = 25 result = cfg.outline_block(current_line, blocks) if result == 0: print(f"Outlined block: {cfg.outlined_block}") # Highlight blocks for executed lines (e.g., from coverage) executed_lines = [10, 12, 15, 18, 25] cfg.highlight_blocks(executed_lines, blocks) # Generate interactive visualization cfg.build_visual( filepath='debug_cfg', format='svg', interactive=True, # Enables highlight/outline styling show=False ) ``` -------------------------------- ### Usage Commands Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Common CLI commands for generating flow charts and debugging. ```sh #!/bin/bash # Install pip3 install py2cfg --user # Generage flow-chart py2cfg --short --format svg --outfile # To also generate a diffable ast file (can help in grading, for example): py2cfg --short --diffable --format svg --outfile # To trace code in pudb while stepping through flow-char: py2cfg --debug ``` -------------------------------- ### Generate CFG Visualizations with `build_visual` Source: https://context7.com/classroomcode/py2cfg/llms.txt Use the `build_visual` method to generate graphviz visualizations of CFGs in various formats like SVG and PDF. Customize output with options for including call graphs, auto-opening files, cleaning intermediate files, specifying output directories, and enabling interactive debugging. ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('example', './example.py') # Basic SVG generation cfg.build_visual( filepath='example_cfg', format='svg', show=False ) # Full options for PDF with call graphs output = cfg.build_visual( filepath='detailed_cfg', format='pdf', calls=True, # Include function call subgraphs show=True, # Auto-open after generation cleanup=True, # Remove intermediate DOT file directory='./output', # Output directory interactive=False, # Enable for debugging mode build_keys=True, # Include shape/color key legend build_own=False, # Build only this CFG level diffable=True # Also generate .ast file for diffing ) # Generate just the key/legend cfg.build_key(format='svg', filename='cfg_key', directory='./output') ``` -------------------------------- ### Format Code with Black Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Execute this command before committing to ensure consistent code style across the project. ```sh black py2cfg/*.py ``` -------------------------------- ### Basic SVG generation Source: https://context7.com/classroomcode/py2cfg/llms.txt Generate a basic SVG control flow graph from a Python file. ```bash py2cfg mycode.py --outfile mycode_cfg ``` -------------------------------- ### Enforce Type Hinting with Mypy Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Run this command to verify that the project adheres to strict type-hinting standards. ```sh mypy --strict --disallow-any-explicit *.py ``` -------------------------------- ### CFG iteration and navigation Source: https://context7.com/classroomcode/py2cfg/llms.txt Build a CFG from a Python file and iterate through all blocks, including nested functions and classes. Access nested function and class CFGs, and find a path from the entry to a final block. ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('module', './module.py') # Iterate all blocks (includes nested functions/classes) all_blocks = list(cfg) print(f"Total blocks: {len(all_blocks)}") # Iterate only top-level blocks own_blocks = list(cfg.own_blocks()) print(f"Top-level blocks: {len(own_blocks)}") # Access nested function CFGs for func_name, func_cfg in cfg.functioncfgs.items(): print(f"Function: {func_name}") print(f" Entry block: {func_cfg.entryblock}") print(f" Final blocks: {len(func_cfg.finalblocks)}") print(f" Is async: {func_cfg.asynchr}") # Access nested class CFGs for class_name, class_cfg in cfg.classcfgs.items(): print(f"Class: {class_name}") # Class CFGs contain their method CFGs for method_name in class_cfg.functioncfgs: print(f" Method: {method_name}") # Find path from entry to final block if cfg.finalblocks: path = cfg.find_path(cfg.finalblocks[0]) print("Path to final block:") for link in path: print(f" {link.source.id} -> {link.target.id}") ``` -------------------------------- ### Generate PDF with shortened strings Source: https://context7.com/classroomcode/py2cfg/llms.txt Generate a PDF control flow graph with shortened strings for better readability. ```bash py2cfg mycode.py --short --format pdf --outfile mycode_cfg ``` -------------------------------- ### CFG.build_visual Source: https://context7.com/classroomcode/py2cfg/llms.txt Generates a visual representation of the control flow graph using graphviz. Supports multiple output formats and customization options including interactive mode for debugging. ```APIDOC ## CFG.build_visual ### Description Generate a visual representation of the control flow graph using graphviz. Supports multiple output formats and customization options including interactive mode for debugging. ### Method POST ### Endpoint /api/cfg/{cfg_id}/visualize ### Parameters #### Path Parameters - **cfg_id** (string) - Required - The ID of the CFG to visualize. #### Query Parameters - **filepath** (string) - Required - The base name for the output file. - **format** (string) - Optional - The output format (e.g., 'svg', 'png', 'pdf'). Defaults to 'svg'. - **calls** (boolean) - Optional - Include function call subgraphs. Defaults to false. - **show** (boolean) - Optional - Auto-open the generated file. Defaults to false. - **cleanup** (boolean) - Optional - Remove intermediate DOT file. Defaults to false. - **directory** (string) - Optional - The directory to save the output file. Defaults to the current directory. - **interactive** (boolean) - Optional - Enable debugging mode. Defaults to false. - **build_keys** (boolean) - Optional - Include shape/color key legend. Defaults to false. - **build_own** (boolean) - Optional - Build only this CFG level (don't include nested CFGs). Defaults to true. - **diffable** (boolean) - Optional - Also generate a .ast file for diffing. Defaults to false. ### Request Example ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('example', './example.py') # Basic SVG generation cfg.build_visual( filepath='example_cfg', format='svg', show=False ) # Full options for PDF with call graphs output = cfg.build_visual( filepath='detailed_cfg', format='pdf', calls=True, # Include function call subgraphs show=True, # Auto-open after generation cleanup=True, # Remove intermediate DOT file directory='./output', # Output directory interactive=False, # Enable for debugging mode build_keys=True, # Include shape/color key legend build_own=False, # Build only this CFG level diffable=True # Also generate .ast file for diffing ) # Generate just the key/legend cfg.build_key(format='svg', filename='cfg_key', directory='./output') ``` ### Response #### Success Response (200) - **output_path** (string) - The path to the generated visual file. #### Response Example ```json { "output_path": "./output/detailed_cfg.pdf" } ``` ``` -------------------------------- ### Shell Command Execution Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Basic command to generate a CFG SVG file. ```py py2cfg --outfile ``` -------------------------------- ### Importing py2cfg Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Using the CFGBuilder class to generate CFGs programmatically. ```py from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('example', './example.py') ``` ```py cfg.build_visual('exampleCFG', 'pdf') ``` -------------------------------- ### Build CFG via JSON-RPC Source: https://context7.com/classroomcode/py2cfg/llms.txt Build a CFG programmatically by sending a JSON-RPC request to the py2cfg server. The response contains the CFG data, which needs to be decoded. ```python import requests import base64 import pickle # Build CFG via JSON-RPC response = requests.get( 'http://localhost:5000/build', json={ 'jsonrpc': '2.0', 'method': 'build_cfg', 'params': { 'filename': '/path/to/mycode.py', 'lineno': 10 # Line number to find CFG containing this line }, 'id': 1 } ) result = response.json()['result'] cfg = pickle.loads(base64.b64decode(result['data'].encode())) print(f"Retrieved CFG: {cfg.name}") ``` -------------------------------- ### Build CFG from File with py2cfg Source: https://context7.com/classroomcode/py2cfg/llms.txt Use `build_from_file` to generate a CFG from a Python source file. Access CFG properties like name, entry block, and final blocks. Iterate through blocks to inspect source code and line numbers. Generates SVG visualizations including function calls. ```python from py2cfg import CFGBuilder # Build CFG from a Python file cfg = CFGBuilder().build_from_file('fibonacci', './examples/fib.py') # Access CFG properties print(f"CFG name: {cfg.name}") print(f"Entry block: {cfg.entryblock}") print(f"Final blocks: {len(cfg.finalblocks)}") # Iterate through all blocks in the CFG for block in cfg: print(f"Block {block.id} at line {block.at()}: {block.get_source()[:50]}...") # Generate visualization as SVG output_path = cfg.build_visual( filepath='fibonacci_cfg', format='svg', calls=True, # Include function call subgraphs show=False, # Don't auto-open the file cleanup=True # Remove intermediate DOT file ) print(f"CFG saved to: {output_path}") ``` -------------------------------- ### Run with pudb debugger Source: https://context7.com/classroomcode/py2cfg/llms.txt Run py2cfg with the pudb debugger for interactive visualization of the control flow graph. ```bash py2cfg mycode.py --debug ``` -------------------------------- ### CFGBuilder.build_from_file Source: https://context7.com/classroomcode/py2cfg/llms.txt Builds a control flow graph from a Python source file. This is the primary method for generating CFGs from existing Python code files. It parses the file, constructs the AST, and builds a complete CFG with support for nested functions and classes. ```APIDOC ## CFGBuilder.build_from_file ### Description Build a control flow graph from a Python source file. This is the primary method for generating CFGs from existing Python code files. It parses the file, constructs the AST, and builds a complete CFG with support for nested functions and classes. ### Method POST ### Endpoint /api/cfg/build_from_file ### Parameters #### Query Parameters - **filename** (string) - Required - The name of the Python file to process. - **entry_point** (string) - Optional - The name of the function or module to start the CFG from. ### Request Body ```json { "source_code": "string" } ``` ### Request Example ```python from py2cfg import CFGBuilder # Build CFG from a Python file cfg = CFGBuilder().build_from_file('fibonacci', './examples/fib.py') # Access CFG properties print(f"CFG name: {cfg.name}") print(f"Entry block: {cfg.entryblock}") print(f"Final blocks: {len(cfg.finalblocks)}") # Iterate through all blocks in the CFG for block in cfg: print(f"Block {block.id} at line {block.at()}: {block.get_source()[:50]}...") # Generate visualization as SVG output_path = cfg.build_visual( filepath='fibonacci_cfg', format='svg', calls=True, # Include function call subgraphs show=False, # Don't auto-open the file cleanup=True # Remove intermediate DOT file ) print(f"CFG saved to: {output_path}") ``` ### Response #### Success Response (200) - **cfg_data** (object) - The generated control flow graph data. - **name** (string) - The name of the CFG. - **entryblock** (string) - The ID of the entry block. - **finalblocks** (array) - A list of IDs of the final blocks. - **blocks** (array) - A list of block objects. - **id** (string) - The ID of the block. - **at** (integer) - The line number the block starts at. - **source** (string) - The source code snippet for the block. #### Response Example ```json { "cfg_data": { "name": "fibonacci", "entryblock": "0", "finalblocks": ["3"], "blocks": [ { "id": "0", "at": 1, "source": "def fibonacci(n):" }, { "id": "1", "at": 2, "source": "if n < 2:" } ] } } ``` ``` -------------------------------- ### Specify custom port for debug server Source: https://context7.com/classroomcode/py2cfg/llms.txt Run py2cfg with the debug option and specify a custom port for the debug server. ```bash py2cfg mycode.py --debug --port 9000 ``` -------------------------------- ### Build SVG graph via JSON-RPC Source: https://context7.com/classroomcode/py2cfg/llms.txt Build an SVG graph of a CFG by sending a JSON-RPC request to the py2cfg server. The SVG data is returned directly and can be saved to a file. ```python import requests import base64 import pickle # Build SVG graph via JSON-RPC response = requests.get( 'http://localhost:5000/build', json={ 'jsonrpc': '2.0', 'method': 'build_graph', 'params': { 'filename': '/path/to/mycode.py', 'lineno': 10, 'build_own': True, 'build_keys': False, 'interactive': True }, 'id': 2 } ) svg_data = response.json()['result'] with open('output.svg', 'w') as f: f.write(svg_data) ``` -------------------------------- ### Iterate through CFG blocks Source: https://context7.com/classroomcode/py2cfg/llms.txt Iterate through all blocks in a CFG, accessing block details like ID, start/end lines, source code, type, function calls, and control flow exits. Also demonstrates searching for a block at a specific line. ```python for block in cfg: # Block identification print(f"Block ID: {block.id}") print(f"Start line: {block.at()}") print(f"End line: {block.end()}") # Get source code in block source = block.get_source() print(f"Source:\n{source}") # Check block type block_type = block.type() print(f"Type: {block_type.__name__ if block_type else 'empty'}") # Function calls within block if block.func_calls: print(f"Calls: {block.get_calls()}") # Control flow exits for exit_link in block.exits: print(f" -> Block {exit_link.target.id}: {exit_link.get_exitcase()}") # Search for block at specific line block = cfg.bsearch(lineno=15) if block: print(f"Found block at line 15: {block}") ``` -------------------------------- ### Generate SVG with diffable AST file Source: https://context7.com/classroomcode/py2cfg/llms.txt Generate an SVG control flow graph with a diffable AST file, useful for grading or tracking changes. ```bash py2cfg mycode.py --short --diffable --format svg --outfile mycode_cfg ``` -------------------------------- ### Build CFG from Source String with py2cfg Source: https://context7.com/classroomcode/py2cfg/llms.txt Use `build_from_src` to generate a CFG directly from a Python source code string. This is useful for analyzing code snippets or dynamically generated code. Supports accessing nested function CFGs and generating PDF visualizations. ```python from py2cfg import CFGBuilder source_code = """ def is_prime(n): if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True result = is_prime(17) """ # Build CFG from source string cfg = CFGBuilder(short=True).build_from_src('prime_checker', source_code) # Access nested function CFGs if 'is_prime' in cfg.functioncfgs: func_cfg = cfg.functioncfgs['is_prime'] print(f"Function CFG: {func_cfg.name}") print(f"Lines: {func_cfg.lineno} to {func_cfg.end_lineno}") # Generate PDF visualization cfg.build_visual( filepath='prime_cfg', format='pdf', calls=True, show=False ) ``` -------------------------------- ### Direct request for CFG Source: https://context7.com/classroomcode/py2cfg/llms.txt Use the `request_cfg` helper function to directly request a CFG object from a running py2cfg server by specifying the file and line number. ```python from py2cfg import request_cfg # Direct request for CFG at specific file and line cfg = request_cfg('mycode.py', lineno=15, hostname='localhost', port=5000) print(f"CFG: {cfg.name}") ``` -------------------------------- ### CFGBuilder.build_from_src Source: https://context7.com/classroomcode/py2cfg/llms.txt Builds a control flow graph directly from a Python source code string. This is useful for analyzing code snippets, generated code, or code that isn't stored in files. ```APIDOC ## CFGBuilder.build_from_src ### Description Build a control flow graph directly from Python source code string. Useful for analyzing code snippets, generated code, or code that isn't stored in files. ### Method POST ### Endpoint /api/cfg/build_from_src ### Parameters #### Query Parameters - **name** (string) - Required - The name to assign to the CFG. - **short** (boolean) - Optional - If true, truncates long strings in the visualization. ### Request Body ```json { "source_code": "string" } ``` ### Request Example ```python from py2cfg import CFGBuilder source_code = """ def is_prime(n): if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True result = is_prime(17) """ # Build CFG from source string cfg = CFGBuilder(short=True).build_from_src('prime_checker', source_code) # Access nested function CFGs if 'is_prime' in cfg.functioncfgs: func_cfg = cfg.functioncfgs['is_prime'] print(f"Function CFG: {func_cfg.name}") print(f"Lines: {func_cfg.lineno} to {func_cfg.end_lineno}") # Generate PDF visualization cfg.build_visual( filepath='prime_cfg', format='pdf', calls=True, show=False ) ``` ### Response #### Success Response (200) - **cfg_data** (object) - The generated control flow graph data. - **name** (string) - The name of the CFG. - **entryblock** (string) - The ID of the entry block. - **finalblocks** (array) - A list of IDs of the final blocks. - **blocks** (array) - A list of block objects. - **id** (string) - The ID of the block. - **at** (integer) - The line number the block starts at. - **source** (string) - The source code snippet for the block. - **functioncfgs** (object) - A dictionary of nested function CFGs. #### Response Example ```json { "cfg_data": { "name": "prime_checker", "entryblock": "0", "finalblocks": ["5"], "blocks": [ { "id": "0", "at": 2, "source": "def is_prime(n):" } ], "functioncfgs": { "is_prime": { "name": "is_prime", "lineno": 2, "end_lineno": 8 } } } } ``` ``` -------------------------------- ### Accessing CFG Blocks Source: https://context7.com/classroomcode/py2cfg/llms.txt The `Block` class represents individual blocks within a control flow graph. It provides access to statements, function calls, and predecessor/successor block links for detailed analysis. ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('analysis', './code.py') ``` -------------------------------- ### Debug with pudb3 Source: https://gitlab.com/classroomcode/py2cfg/-/blob/master/README.md Command to run py2cfg in debug mode. ```bash py2cfg --debug ``` -------------------------------- ### py2cfg Short Mode for String Truncation Source: https://context7.com/classroomcode/py2cfg/llms.txt Configure `CFGBuilder` with `short=True` to truncate long strings in CFG visualizations. This provides a cleaner graph by shortening strings exceeding 20 characters. Compares CFGs generated with and without short mode. ```python from py2cfg import CFGBuilder # Without short mode - full strings displayed builder_full = CFGBuilder(short=False) cfg_full = builder_full.build_from_file('full', './mycode.py') # With short mode - strings truncated at 20 chars builder_short = CFGBuilder(short=True) cfg_short = builder_short.build_from_file('short', './mycode.py') # Generate both for comparison cfg_full.build_visual('output_full', format='svg', show=False) cfg_short.build_visual('output_short', format='svg', show=False) ``` -------------------------------- ### Block Class Source: https://context7.com/classroomcode/py2cfg/llms.txt Represents an individual block within the control flow graph. Each block contains statements, function calls, and links to predecessor and successor blocks. ```APIDOC ## Block Class ### Description Access individual blocks in the control flow graph. Each block contains statements, function calls, and links to predecessor and successor blocks. ### Method GET ### Endpoint /api/cfg/{cfg_id}/blocks/{block_id} ### Parameters #### Path Parameters - **cfg_id** (string) - Required - The ID of the CFG. - **block_id** (string) - Required - The ID of the block to retrieve. ### Request Example ```python from py2cfg import CFGBuilder cfg = CFGBuilder().build_from_file('analysis', './code.py') # Assuming 'block_id_1' is a valid block ID from the CFG # block_data = get_block_details(cfg_id='analysis', block_id='block_id_1') # print(block_data) ``` ### Response #### Success Response (200) - **block_details** (object) - Details of the requested block. - **id** (string) - The ID of the block. - **at** (integer) - The line number the block starts at. - **source** (string) - The source code snippet for the block. - **predecessors** (array) - A list of IDs of predecessor blocks. - **successors** (array) - A list of IDs of successor blocks. #### Response Example ```json { "block_details": { "id": "1", "at": 5, "source": "if n % i == 0:", "predecessors": ["0"], "successors": ["2", "3"] } } ``` ``` -------------------------------- ### Decorator usage for automatic CFG retrieval Source: https://context7.com/classroomcode/py2cfg/llms.txt Use the `request_cfg` decorator to automatically retrieve the CFG for a decorated function. The CFG is stored in a provided holder list. ```python from py2cfg import request_cfg # Decorator usage - automatically retrieves CFG for decorated function cfg_holder = [None] @request_cfg(cfg_holder, hostname='localhost', port=5000) def my_function(): x = 10 if x > 5: return x * 2 return x # Call function to trigger CFG retrieval my_function() # Access the CFG cfg = cfg_holder[0] print(f"Function CFG retrieved: {cfg.name}") for block in cfg: print(f" Block {block.id}: {block.get_source()[:30]}...") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.