Architecture¶
Two entry points, one pipeline¶
dicogis-cli (dicogis/cli, Typer) and dicogis-gui (dicogis/ui, PyQt6) are thin wrappers around the same core packages:
flowchart LR
cli["dicogis-cli<br/>dicogis.cli"] --> listing
gui["dicogis-gui<br/>dicogis.ui"] --> listing
listing["Listing<br/>dicogis.listing"] --> readers["Reading<br/>dicogis.georeaders"]
pg[("PostGIS<br/>pg_service.conf")] --> readers
readers --> md["MetaDataset<br/>dicogis.models"]
md --> export["Serialization<br/>dicogis.export"]
export --> xlsx[".xlsx"]
export --> json["JSON"]
export --> iso["ISO 19139"]
json --> udata["uData<br/>dicogis.publishing"]
iso --> gn["GeoNetwork<br/>dicogis.publishing"]
When changing the core, check how both entry points call it: the GUI runs the long tasks in QThread workers (dicogis/ui/workers.py) and wires the progress bars, where the CLI passes None.
Rules enforced by tests:
nothing outside
dicogis/cliimports it, nor Typer, Rich or Click (tests/test_cli_isolation.py): the GUI must also run inside QGIS, which ships none of them. Logic needed by both goes into a core package.GDAL is optional (the
gdalextra): the GDAL-dependent imports of the entry points are deferred into the functions, behindGDAL_IS_AVAILABLE(dicogis/utils/environment.py)PyQt6 is optional (the
guiextra):dicogis/ui/__init__.pystays empty,dicogis-guiimportsQtWidgetslazily (tests/test_ui_optional_pyqt6.py)
Processing pipeline¶
Listing (
dicogis/listing/geodata_listing.py):find_geodata_files()walks the folder tree and sorts the files by format.check_usable_pg_services()checks the requested services againstpg_service.conf.Reading (
dicogis/georeaders/):GeoReaderBaseholds the shared GDAL logic (errors, CRS, extent, fields, companion files, size). Each format-specific reader subclasses it and fills aMetaDataset(dicogis/models/metadataset.py), the in-memory description of one dataset.Orchestration (
dicogis/georeaders/process_files.py):ProcessingFilesmaps each format to its reader (MATRIX_FORMAT_GEOREADER), reads the listed files and feeds eachMetaDatasetto a serializer.ReadPostGISdoes the same for the layers of a database.Serialization (
dicogis/export/):MetadatasetSerializerBaseand its factoryget_serializer_from_parameters()pick the serializer of the output format:to_xlsx.py,to_json.py(flavorsdicogisandudata),to_iso19139.py.
Adding a file format means: adding it to dicogis/constants.py (FormatsVector/FormatsRaster, FORMAT_TO_GDAL_DRIVERS), detecting it in find_geodata_files(), registering it in MATRIX_FORMAT_GEOREADER with its opt_analyze_* flag, and reusing or extending a reader.
Adding an output format means: a serializer in dicogis/export, registered in the factory and in OutputFormats (dicogis/constants.py), and in FOLDER_OUTPUT_FORMATS (dicogis/export/output_path.py) if it writes one file per dataset.
Catalog records and publication¶
CatalogRecord (dicogis/export/catalog_record.py) is the pivot between a MetaDataset and the catalog formats: the single list of the fields DicoGIS manages. It holds the location of the dataset only when asked for. A record is identified by MetaDataset.uuid, derived from the location of the dataset: changing it changes the identifier of what’s already published.
dicogis/publishing/ holds one module per catalog (udata.py, geonetwork.py), each with a publish_metadata_folder() returning a PublishReport, depending on neither Typer nor Qt. They reach the network through dicogis/utils/http/, never requests directly: HttpClient is implemented by RequestsHttpClient and QgisHttpClient (network stack of QGIS), picked at runtime from DICOGIS_HTTP_BACKEND.
The GUI runs a publication in a QThread, or in a QgsTask inside QGIS (dicogis/publishing/qgis_task.py). Both report and cancel through ProgressReporter.
GUI¶
The GUI is meant to be reusable inside QGIS (>= 4.4, Qt >= 6.8), where Qt is reached through qgis.PyQt:
Qt is always imported through
dicogis.ui.qt_compat, which mirrors theqgis.PyQtlayout and picks the binding at first import (DICOGIS_QT_API).tests/test_ui_qt_compat.pyfails on a direct import of a binding.widgets are defined in Qt Designer
.uifiles, loaded withuic.loadUi(), the project’s own widgets placed by promotion.tests/test_ui_widgets_in_ui_files.pyfails on a widget built in Python.modules and widgets follow naming conventions (
dlg_,wdg_,mw_modules;btn_,cbx_,lne_… widgets), see the contributing guidelines
Translations¶
The output and the CLI use TextsManager (dicogis/locale/lang_*.xml), the GUI Qt translations (self.tr()): see translations.