pySimBlocks.tools.generate_blocks_index

pySimBlocks.tools.generate_blocks_index.iter_python_files(base_path)[source]

Yield paths to all non-__init__ Python files under base_path.

Parameters:

base_path – Root directory to walk.

Yields:

Absolute path strings to .py files.

pySimBlocks.tools.generate_blocks_index.find_block_classes(filepath: str | Path) list[str][source]

Return names of all classes that inherit (directly or indirectly) from Block.

Uses a name-based heuristic: a class is considered a Block subclass if "block" appears (case-insensitive) in its own name or in any ancestor name reachable within the same file.

Parameters:

filepath – Path to the Python source file to analyse.

Returns:

List of class names identified as Block subclasses.

pySimBlocks.tools.generate_blocks_index.generate_blocks_index() dict[source]

Scan the blocks directory and write the YAML block index.

For each block group (subdirectory of pySimBlocks/blocks/), scans Python files, identifies Block subclasses, and records their class name and dotted module path. The result is written to pySimBlocks/project/pySimBlocks_blocks_index.yaml.

Returns:

The generated index dict (mirrors the written YAML content).