I would like to rewrite some of my QGIS plugins to use more common functions used by all of my plugins.
There exist some older functions (GIS2) like
and something newer like
Are there any other known collections of PyQGIS3 common functions that can be used to do basic tasks like load vectorlayers, show comboboxes, create toolbar-actions or something like that without having to write these code-snippets everytime on your own?
If I want to lad a vectorlayer I can make use of the function load_layer from https://github.com/qgis/pyqgis_wrappers/blob/master/parfait/layer_wrappers.py
def load_layer(filename, name = None): ''' Tries to load a layer from the given file :param filename: the path to the file to load. :param name: the name to use for adding the layer to the current project. If not passed or None, it will use the filename basename ''' name = name or os.path.splitext(os.path.basename(filename)) qgslayer = QgsVectorLayer(filename, name, 'ogr') if not qgslayer.isValid(): qgslayer = QgsRasterLayer(filename, name) if not qgslayer.isValid(): raise RuntimeError('Could not load layer: ' + unicode(filename)) return qgslayer