Core Module

Core functionality for ModuFlow.

This package provides the core functionality for ModuFlow, including configuration handling and path management.

Config

Configuration management for ModuFlow.

This module provides functionality for working with YAML configuration files, including reading, writing, and merging section configurations.

class moduflow.core.config.ConfigManager(project_root: str | None = None)[source]

Bases: object

Manager for ModuFlow configuration files.

add_file_to_sections(file_path: str, section_names: List[str]) None[source]

Add a file to multiple sections.

Parameters:
  • file_path – Path to the file.

  • section_names – List of section names.

compile_config() Dict[str, Any][source]

Compile all section configurations into a single configuration.

Returns:

Dictionary containing the compiled configuration.

find_files_in_multiple_sections() Dict[str, List[str]][source]

Find files that are used in multiple sections.

Returns:

Dictionary mapping file paths to lists of section names.

init_config() None[source]

Initialize the configuration directory structure.

read_all_section_configs() Dict[str, Dict[str, Any]][source]

Read all section configuration files.

Returns:

Dictionary mapping section names to their configurations.

read_compiled_config() Dict[str, Any][source]

Read the compiled configuration file.

Returns:

Dictionary containing the compiled configuration.

read_section_config(section_name: str) Dict[str, Any][source]

Read a section configuration file.

Parameters:

section_name – Name of the section.

Returns:

Dictionary containing the section configuration.

Raises:

FileNotFoundError – If the section config doesn’t exist.

write_compiled_config(config: Dict[str, Any]) None[source]

Write the compiled configuration file.

Parameters:

config – Dictionary containing the compiled configuration.

write_section_config(section_name: str, config: Dict[str, Any]) None[source]

Write a section configuration file.

Parameters:
  • section_name – Name of the section.

  • config – Dictionary containing the section configuration.

Exceptions

Exceptions for ModuFlow.

This module provides custom exceptions for ModuFlow.

exception moduflow.core.exceptions.CompilationError[source]

Bases: ModuFlowError

Error during compilation.

exception moduflow.core.exceptions.ConfigError[source]

Bases: ModuFlowError

Error in configuration.

exception moduflow.core.exceptions.FileError[source]

Bases: ModuFlowError

Error related to files.

exception moduflow.core.exceptions.ModuFlowError[source]

Bases: Exception

Base exception for all ModuFlow errors.

exception moduflow.core.exceptions.SectionError[source]

Bases: ModuFlowError

Error related to sections.

exception moduflow.core.exceptions.SectionNotFoundError[source]

Bases: SectionError

Section not found.

Paths

Path management for ModuFlow.

This module provides utilities for working with paths in ModuFlow projects.

class moduflow.core.paths.PathManager(project_root: str | None = None)[source]

Bases: object

Manager for paths in a ModuFlow project.

ensure_directories() None[source]

Ensure that all required directories exist.

get_compiled_config_path() Path[source]

Get the path to the compiled configuration file.

Returns:

Path to the compiled configuration file.

get_design_file_path(section_name: str) Path[source]

Get the path to a section design file.

Parameters:

section_name – Name of the section.

Returns:

Path to the section design file.

get_file_paths_by_pattern(pattern: str) list[Path][source]

Get paths to files matching a pattern.

Parameters:

pattern – Glob pattern to match files.

Returns:

List of matching file paths.

get_project_output_dir() Path[source]

Get the output directory for the entire project.

Returns:

Path to the project output directory.

get_relative_path(path: Path) str[source]

Get a path relative to the project root.

Parameters:

path – Absolute path.

Returns:

Path relative to the project root.

get_section_config_path(section_name: str) Path[source]

Get the path to a section configuration file.

Parameters:

section_name – Name of the section.

Returns:

Path to the section configuration file.

get_section_output_dir(section_name: str) Path[source]

Get the output directory for a section.

Parameters:

section_name – Name of the section.

Returns:

Path to the section output directory.