Utils Module
Utilities package for ModuFlow.
This package provides utility functions for ModuFlow.
Helpers
Helper functions for ModuFlow.
This module provides utility functions for ModuFlow.
- moduflow.utils.helpers.camel_to_snake(name: str) str[source]
Convert a camelCase or PascalCase name to snake_case.
- Parameters:
name – Name to convert.
- Returns:
snake_case name.
- moduflow.utils.helpers.find_project_root(current_dir: str | None = None) Path[source]
Find the project root directory.
This looks for a .moduflow directory or a git repository.
- Parameters:
current_dir – Directory to start from. If None, uses current directory.
- Returns:
Path to the project root.
- Raises:
FileNotFoundError – If project root cannot be found.
- moduflow.utils.helpers.get_terminal_width() int[source]
Get the width of the terminal.
- Returns:
Width of the terminal in characters.
- moduflow.utils.helpers.is_path_within(child_path: Path, parent_path: Path) bool[source]
Check if a path is within another path.
- Parameters:
child_path – Child path to check.
parent_path – Parent path to check against.
- Returns:
True if child_path is within parent_path, False otherwise.
- moduflow.utils.helpers.list_python_modules(directory: Path) List[str][source]
List Python modules in a directory.
- Parameters:
directory – Directory to search in.
- Returns:
List of module names.
- moduflow.utils.helpers.normalize_path(path: str) str[source]
Normalize a path for the current platform.
- Parameters:
path – Path to normalize.
- Returns:
Normalized path.
- moduflow.utils.helpers.run_command(cmd: List[str], cwd: Path | None = None) Tuple[int, str, str][source]
Run a command and return its output.
- Parameters:
cmd – Command to run as a list of strings.
cwd – Working directory. If None, uses current directory.
- Returns:
Tuple of (return_code, stdout, stderr)