dicogis.utils.progress module

Name: Progress Purpose: Toolkit-agnostic contract used by the processing pipeline to

report progress and to be told to stop.

Author: Julien Moura (@geojulien)

exception dicogis.utils.progress.OperationCanceled

Bases: Exception

Raised by the processing pipeline when its progress reporter asked it to stop. Distinct from a real error: the operation didn’t fail, a caller (typically an end-user hitting a cancel button) interrupted it.

class dicogis.utils.progress.ProgressReporter(*args, **kwargs)

Bases: Protocol

Toolkit-agnostic contract for reporting processing progress and for letting the caller interrupt it.

Kept free of any Qt/GDAL import on purpose: it’s implemented by the PyQt6 GUI (dicogis.ui.workers.QtProgressReporter), it’s passed as None by dicogis-cli, and it’s what a QGIS plugin would implement on top of QgsTask.setProgress()/QgsTask.isCanceled(). Which is also why it lives here rather than next to the pipeline that consumes it: importing it from dicogis.georeaders.process_files would drag GDAL in (see that module’s imports), and dicogis.listing must stay importable without GDAL.

__init__(*args, **kwargs)
increment(amount=1)

Increment the progress counter.

Return type:

None

is_canceled()

Whether the running operation has been asked to stop.

Polled cooperatively by the pipeline: implementations must be cheap and safe to call from any thread, since the parallel folder scan calls it from its worker threads.

Return type:

bool

set_message(message)

Update the currently displayed status message.

Return type:

None

set_total(total)

Set the total/maximum value of the progress counter.

Return type:

None

dicogis.utils.progress.raise_if_canceled(progress_reporter)

Raise OperationCanceled if the reporter asked the operation to stop.

Parameters:

progress_reporter (ProgressReporter | None) – reporter to poll. None (e.g. from dicogis-cli, which has nothing to cancel with) never cancels.

Raises:

OperationCanceled – if the reporter reports a cancellation request.

Return type:

None