Coverage for C:\Program Files\QGIS 3.10\apps\qgis-ltr\python\qgis\core\additions\providermetadata.py: 60%
10 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-10 14:40 +0900
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-10 14:40 +0900
1# -*- coding: utf-8 -*-
3"""
4***************************************************************************
5 providermetadata.py
6 ---------------------
7 Date : June 2019
8 Copyright : (C) 2019 by Martin Dobias
9 Email : wonder dot sk at gmail dot com
10***************************************************************************
11* *
12* This program is free software; you can redistribute it and/or modify *
13* it under the terms of the GNU General Public License as published by *
14* the Free Software Foundation; either version 2 of the License, or *
15* (at your option) any later version. *
16* *
17***************************************************************************
18"""
20from qgis._core import QgsProviderMetadata
23class PyProviderMetadata(QgsProviderMetadata):
24 """ wrapper around QgsProviderMetadata to keep the existing Python code running which registers
25 data providers by passing a custom python createProvider() function to QgsProviderMetadata
26 constructor. The proper new way of doing it is to subclass QgsProviderMetadata and implement
27 its virtual functions.
29 TODO: QGIS 4 - remove this wrapper (only subclassing of QgsProviderMetadata should be used)
30 """
32 # this is a workaround to keep references to metadata classes
33 # so they are not removed when the variable gets out of scope
34 _kept_refs = []
36 def __init__(self, key, description, library_or_create_func=None):
37 super().__init__(key, description)
38 if callable(library_or_create_func):
39 self.createProvider = library_or_create_func
40 PyProviderMetadata._kept_refs.append(self)
43PyProviderMetadata.__doc__ = QgsProviderMetadata.__doc__