doFolder.cli.util module¶
Utility functions and constants for the doFolder CLI module.
This module provides common utilities used across different CLI components, including version information handling and argument parser configuration.
- class doFolder.cli.util.ConsoleController(traceback: bool, noColor: bool, muteWarning: bool = False, console: Console = <console width=80 None>, consoleWidth: int | None = None)¶
Bases:
objectController for console output with styling and error handling.
Manages console output formatting, color settings, and exception handling with support for traceback display and warning muting.
- console: Console = <console width=80 None>¶
- consoleWidth: int | None = None¶
- expHook(e: BaseException)¶
Handle and display exceptions with appropriate formatting.
- Parameters:
e – The exception to handle and display.
- muteWarning: bool = False¶
- noColor: bool¶
- traceback: bool¶
- warn(content: str)¶
Display a warning message if warnings are not muted.
- Parameters:
content – The warning message content to display.
- doFolder.cli.util.FULL_VERSION_STRING = 'doFolder 2.3.0-beta.5 From Python 3.14.3 (main, Feb 4 2026, 13:50:59) [GCC 13.3.0](/opt/hostedtoolcache/Python/3.14.3/x64/bin/python)'¶
Full version string including Python version and executable path
- class doFolder.cli.util.UnitShow(unitNames: list[tuple[int, str]], noneName: str = 'N/A')¶
Bases:
objectFormatter for displaying values with appropriate unit scaling.
Converts numeric values to human-readable format with appropriate units (e.g., bytes to KB/MB/GB, seconds to minutes/hours/days).
- noneName: str = 'N/A'¶
- unitNames: list[tuple[int, str]]¶
- doFolder.cli.util.VERSION_STRING = 'doFolder 2.3.0-beta.5'¶
Short version string containing package name and version
- doFolder.cli.util.addConsoleInfo(parser: ArgumentParser)¶
Add console information arguments to an ArgumentParser.
- doFolder.cli.util.addVersionInfo(parser: ArgumentParser)¶
Add version information arguments to an ArgumentParser.
This function adds two version-related arguments: - -v, –version: Shows short version information - -vv, –full-version: Shows detailed version information including Python details
- Parameters:
parser (argparse.ArgumentParser) – The argument parser to add version info to.
Example
>>> parser = argparse.ArgumentParser() >>> addVersionInfo(parser) >>> # Parser now has -v/--version and -vv/--full-version arguments
- doFolder.cli.util.createControllerFromArgs(args: Namespace)¶
Create a ConsoleController from parsed command-line arguments.
- Parameters:
args – Parsed arguments containing console control options.
- Returns:
ConsoleController instance configured from arguments.
- doFolder.cli.util.getBestInvocationForThisPython() str¶
Try to figure out the best way to invoke the current Python.
This function was copied from the pip package. It attempts to determine the most appropriate command to invoke the current Python
Thank you to the team that maintains pip. Your code is very useful.
- doFolder.cli.util.idGenerator()¶
Generate sequential integer IDs starting from 1.
- Returns:
Generator yielding sequential integers.