Class: QgsProviderRegistry¶
-
class
qgis.core.
QgsProviderRegistry
¶ Bases:
sip.wrapper
A registry / canonical manager of data providers.
This is a Singleton class that manages data provider access.
Providers can be either loaded via libraries or native providers that are included in the core QGIS installation and accessed through function pointers.
Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable. QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key). For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal, ogr and postgres.
Enums
Methods
Creates a new instance of a provider.
Returns a new QLibrary for the specified
providerKey
.Returns a new widget for selecting layers from a provider.
Returns a string containing the available database drivers
Breaks a provider data source URI into its component paths (e.g.
Returns a string containing the available directory drivers
Returns mesh’s dataset file filter string
Returns mesh file filter string
Returns raster file filter string
Returns vector file filter string
Gets pointer to provider function
Means of accessing canonical single instance
Returns path for the library of the provider.
Returns the library directory where plugins are found.
Returns list of provider plugins found
Returns a string containing the available protocol drivers
Returns the provider capabilities
Returns list of available providers by their keys
Returns metadata of the provider or
None
if not foundregister a new vector data provider from its
providerMetadata
Sets library directory where to search for plugins
Signals
Attributes
-
Embedded
= 1¶
-
Manager
= 2¶
-
None
= 0¶
-
class
WidgetMode
¶ Bases:
int
-
createProvider
(self, providerKey: str, dataSource: str, options: QgsDataProvider.ProviderOptions = QgsDataProvider.ProviderOptions()) → QgsDataProvider¶ Creates a new instance of a provider.
- Parameters
providerKey – identifier of the provider
dataSource – string containing data source for the provider
options – provider options
- Returns
new instance of provider or
None
on error
-
createProviderLibrary
(self, providerKey: str) → QLibrary¶ Returns a new QLibrary for the specified
providerKey
. Ownership of the returned object is transferred to the caller and the caller is responsible for deleting it.If the provider uses direct provider function pointers instead of a library
None
will be returned.
-
createSelectionWidget
(self, providerKey: str, parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags(), widgetMode: QgsProviderRegistry.WidgetMode = QgsProviderRegistry.WidgetMode.None) → QWidget¶ Returns a new widget for selecting layers from a provider. Either the
parent
widget must be set or the caller becomes responsible for deleting the returned widget.
-
databaseDrivers
(self) → str¶ Returns a string containing the available database drivers
-
decodeUri
(self, providerKey: str, uri: str) → Dict[str, Any]¶ Breaks a provider data source URI into its component paths (e.g. file path, layer name).
- Parameters
providerKey – identifier of the provider
uri – uri string
- Returns
map containing components. Standard components include “path”, “layerName”, “url”.
Note
this function may not be supported by all providers, an empty map will be returned in such case
New in version 3.4.
-
directoryDrivers
(self) → str¶ Returns a string containing the available directory drivers
-
fileMeshDatasetFilters
(self) → str¶ Returns mesh’s dataset file filter string
Returns a string suitable for a QFileDialog of mesh datasets file formats supported by all data providers.
This walks through all data providers appending calls to their fileMeshFilters to a string, which is then returned.
See also
New in version 3.6.
-
fileMeshFilters
(self) → str¶ Returns mesh file filter string
Returns a string suitable for a QFileDialog of mesh file formats supported by all data providers.
This walks through all data providers appending calls to their fileMeshFilters to a string, which is then returned.
See also
New in version 3.6.
-
fileRasterFilters
(self) → str¶ Returns raster file filter string
Returns a string suitable for a QFileDialog of raster file formats supported by all data providers.
This walks through all data providers appending calls to their buildSupportedRasterFileFilter to a string, which is then returned.
Note
This replaces
QgsRasterLayer.buildSupportedRasterFileFilter()
-
fileVectorFilters
(self) → str¶ Returns vector file filter string
Returns a string suitable for a QFileDialog of vector file formats supported by all data providers.
This walks through all data providers appending calls to their fileVectorFilters to a string, which is then returned.
note
It’d be nice to eventually be raster/vector neutral.
-
function
(self, providerKey: str, functionName: str) → sip.voidptr¶ Gets pointer to provider function
- Parameters
providerKey – identifier of the provider
functionName – name of function
- Returns
pointer to function or
None
on error. If the provider uses direct provider function pointers instead of a libraryNone
will be returned.
-
instance
(pluginPath: str = '') → QgsProviderRegistry¶ Means of accessing canonical single instance
-
library
(self, providerKey: str) → str¶ Returns path for the library of the provider.
If the provider uses direct provider function pointers instead of a library an empty string will be returned.
-
libraryDirectory
(self) → QDir¶ Returns the library directory where plugins are found.
-
pluginList
(self, asHtml: bool = False) → str¶ Returns list of provider plugins found
-
protocolDrivers
(self) → str¶ Returns a string containing the available protocol drivers
-
providerCapabilities
(self, providerKey: str) → int¶ Returns the provider capabilities
- Parameters
providerKey – identifier of the provider
New in version 2.6.
-
providerList
(self) → List[str]¶ Returns list of available providers by their keys
-
providerMetadata
(self, providerKey: str) → QgsProviderMetadata¶ Returns metadata of the provider or
None
if not found
-
registerGuis
(self, widget: QWidget)¶
-
registerProvider
(self, providerMetadata: QgsProviderMetadata) → bool¶ register a new vector data provider from its
providerMetadata
- Returns
True
on success,False
if a provider with the same key was already registered
Note
ownership of the QgsProviderMetadata instance is transferred to the registry
New in version 3.2.
-
setLibraryDirectory
(self, path: QDir)¶ Sets library directory where to search for plugins
-