AlgorithmFactory
Import
from pyqgis_wrapper.processing import AlgorithmFactory
AlgorithmFactory
¶
Factory for QgsProcessingAlgorithm
fetch(name, provider=None, exact_match=False)
staticmethod
¶
Allows to search the processing registry for a specific algorithm. Caller can define a partial name (insensitive to case) and optionnaly an existing provider such as : - "3d" - "gdal" - "grass" - "native" - "pdal" - "qgis" - "saga" - "sagang" - "model" - "script"
The method will return two list : matching algorithm ids and a short display string of the algorithm to help selecting the right one.
Caller can then call the build method with the wanted alg id by either
slicing the list or copy pasting the string id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Partial or total name. Alg will return any algoirtmh that matches the name in his algorithm id or display name. |
required |
provider
|
typing.Optional[typing.Union[str, pyqgis_wrapper.processing.algorithms.ProviderType]]
|
Provider to perform an advanced filter, defaults to None |
None
|
exact_match
|
bool
|
Perform an exact search, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
Tuple[List[str], List[str]]
|
List of matching algorithm ids and list of display name of the matching algorithm. |
Source code in pyqgis_wrapper/processing/algorithms.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
build(algorithm_id)
classmethod
¶
Return a dynamically created subclass of QgisAlgorithm with the given algorithm_id. Caches the result for reuse.
The algorithm can then be used normally by calling apply and optionnaly build_parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm_id
|
str
|
Matching algoirthm id. To be sure of the match you can use the |
required |
Returns:
| Type | Description |
|---|---|
Type[QgisAlgorithm]
|
An instance of QgisAlgorithm or any of its subclasses dynamically created. |
Source code in pyqgis_wrapper/processing/algorithms.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
AlgorithmType
¶
Bases: str, enum.Enum
Class to store algorithm type and base class to build dynamically.
base_class()
¶
Link the algorithm type to the base class. You can ADD or UPDATE the dict when needed
Source code in pyqgis_wrapper/processing/algorithms.py
43 44 45 46 47 48 49 50 51 52 53 | |
ProviderType
¶
Bases: str, enum.Enum
Store the available QgsProcessingProvider to avoid typo
TODO: Dynamically build available providers