doFolder.cli.hash module

CLI module for hash calculation functionality.

This module provides command-line interface for calculating hash values of files using various algorithms with support for progress tracking and parallel processing.

class doFolder.cli.hash.AlgorithmFilesAction(option_strings, dest, nargs=None, **kwargs)

Bases: Action

Custom argparse action for handling algorithm and file combinations.

Parses command-line arguments in the format: algorithms,… file1 file2 … where algorithms is a comma-separated list of hash algorithms.

class doFolder.cli.hash.CalcProgress(*, consoleController: ConsoleController, auto_refresh: bool = True, refresh_per_second: float = 3, speed_estimate_period: float = 30, transient: bool = False, redirect_stdout: bool = True, redirect_stderr: bool = True, get_time: Callable[[], float] | None = None, disable: bool = False, expand: bool = False, showRunningOnly: bool = False)

Bases: Progress

Progress tracker for hash calculation tasks.

Extends Rich Progress to provide custom progress tracking for multiple concurrent hash calculation tasks with detailed status information.

getTaskId(task: CalcTask) TaskID

Get or create a Rich progress task ID for a CalcTask.

Parameters:

task – The CalcTask to get an ID for.

Returns:

Rich progress TaskID for the given task.

refreshCalcTask() None

Refresh progress display for all tracked tasks.

showRunningOnly: bool = False
taskList: list[CalcTask]
taskMap: dict[int, TaskID]
traceTask(*args: CalcTask)

Add tasks to be tracked by this progress instance.

Parameters:

*args – CalcTask instances to track.

updateTask(task: CalcTask)

Update progress display for a specific task.

Parameters:

task – The CalcTask to update progress for.

class doFolder.cli.hash.CalcTask(feature: ~doFolder.hashing.executor.FutureWithProgress[dict[str, ~doFolder.hashing.util.FileHashResult]], result: dict[str, ~doFolder.hashing.util.FileHashResult] | None, file: ~doFolder.fileSystem.classes.File, algorithms: set[str], showName: str, id: int = <factory>)

Bases: object

Represents a hash calculation task with progress tracking.

feature

Future object with progress tracking for the calculation.

Type:

doFolder.hashing.executor.FutureWithProgress[dict[str, doFolder.hashing.util.FileHashResult]]

result

The result of the hash calculation, if completed.

Type:

dict[str, doFolder.hashing.util.FileHashResult] | None

file

The file being hashed.

Type:

doFolder.fileSystem.classes.File

algorithms

Set of hash algorithms to apply.

Type:

set[str]

id

Unique identifier for the task.

Type:

int

algorithms: set[str]
feature: FutureWithProgress[dict[str, FileHashResult]]
property fields

Get formatted field values for progress display.

Returns:

Dictionary of formatted fields for progress bar display.

file: File
id: int
result: dict[str, FileHashResult] | None
showName: str
doFolder.cli.hash.getShortDisplayNames(paths: list[Path]) dict[Path, Path]

Generate short display names for paths by resolving conflicts.

When multiple paths have the same filename, returns progressively longer path segments until all names are unique.

Parameters:

paths – List of Path objects to generate display names for.

Returns:

Dictionary mapping original paths to their shortened display names.

doFolder.cli.hash.hashCli(arguments: Sequence[str] | None = None, prog='buildDoc.py') int

Main CLI function for hash calculation commands.

Parameters:

arguments – Optional sequence of command-line arguments. If None, uses sys.argv.

Returns:

Exit code (0 for success, non-zero for failure).