profile_manager.handlers.data_sources module

class profile_manager.handlers.data_sources.Rule(section: str, regex: str)[source]

Bases: object

Section and regex for find data source connections in a QGIS3.ini file.

regex: str
section: str
profile_manager.handlers.data_sources.collect_data_sources(ini_path: Path) → dict[str, dict[str, dict[str, dict[str, str]]]][source]

Collect all data sources and their ini entries (=options and values inside sections)

profile_manager.handlers.data_sources.collect_data_sources_of_provider(ini_path: Path, provider: str) → dict[str, dict[str, dict[str, str]]][source]

Returns all data source connections of the specified provider in the INI file.

Pseudo example:

{
    "data_source_name1": {
        "section1": {
            "option1": "value1",
            "option2": "value2",
            ...
        },
        "section2": {
            ...
        },
    },
    "data_source_name2": {
        ...
    },
    ...
}
Parameters:
  • ini_path (str) – Path of the INI file to read

  • provider (str) – Name of the provider to gather connections of

Returns:

Discovered data source connections with their sections, options and values

Raises:

NotImplementedError – If the provider name is not (yet) known here

profile_manager.handlers.data_sources.import_data_sources(qgis_ini_file: Path, data_sources_to_be_imported: dict[str, list[str]], available_data_sources: dict[str, dict[str, dict[str, dict[str, str]]]])[source]

Import data sources to a QGIS3.ini file.

Parameters:
  • qgis_ini_file – Path of the QGIS3.ini file to import data sources to

  • data_sources_to_be_imported – Provider name -> List of data source names to import

  • available_data_sources – Available data sources, will be used find which options and values have to be imported in which sections. Providers -> Data sources -> Sections -> Options -> Values

profile_manager.handlers.data_sources.remove_data_sources(qgis_ini_file: Path, data_sources_to_be_removed: dict[str, list[str]], available_data_sources: dict[str, dict[str, dict[str, dict[str, str]]]])[source]

Handles data source removal from file

Parameters:
  • qgis_ini_file – Path of the QGIS3.ini file to remove data sources from

  • data_sources_to_be_removed – Provider name -> List of data source names to remove

  • available_data_sources – Available data sources, will be used find which options in which sections have to be removed. Providers -> Data sources -> Sections -> Options