mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Update processing.algorithmHelp for new API
This commit is contained in:
parent
c59aeab544
commit
77351fdba4
@ -37,6 +37,7 @@ except ImportError:
|
|||||||
|
|
||||||
from qgis.core import (QgsApplication,
|
from qgis.core import (QgsApplication,
|
||||||
QgsProcessingAlgorithm,
|
QgsProcessingAlgorithm,
|
||||||
|
QgsProcessingParameterEnum,
|
||||||
QgsProcessingParameterFeatureSink,
|
QgsProcessingParameterFeatureSink,
|
||||||
QgsProcessingParameterVectorDestination,
|
QgsProcessingParameterVectorDestination,
|
||||||
QgsProcessingParameterRasterDestination,
|
QgsProcessingParameterRasterDestination,
|
||||||
@ -47,30 +48,37 @@ from processing.core.parameters import ParameterSelection
|
|||||||
from processing.gui.Postprocessing import handleAlgorithmResults
|
from processing.gui.Postprocessing import handleAlgorithmResults
|
||||||
|
|
||||||
|
|
||||||
def algorithmOptions(id):
|
|
||||||
"""Prints all algorithm options with their values.
|
|
||||||
"""
|
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById(id)
|
|
||||||
if alg is not None:
|
|
||||||
opts = ''
|
|
||||||
for param in alg.parameterDefinitions():
|
|
||||||
if isinstance(param, ParameterSelection):
|
|
||||||
opts += '{} ({})\n'.format(param.name(), param.description())
|
|
||||||
for option in enumerate(param.options):
|
|
||||||
opts += '\t{} - {}\n'.format(option[0], option[1])
|
|
||||||
print(opts)
|
|
||||||
else:
|
|
||||||
print('Algorithm "{}" not found.'.format(id))
|
|
||||||
|
|
||||||
|
|
||||||
def algorithmHelp(id):
|
def algorithmHelp(id):
|
||||||
"""Prints algorithm parameters with their types. Also
|
"""Prints algorithm parameters with their types. Also
|
||||||
provides information about options if any.
|
provides information about options if any.
|
||||||
"""
|
"""
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById(id)
|
alg = QgsApplication.processingRegistry().algorithmById(id)
|
||||||
if alg is not None:
|
if alg is not None:
|
||||||
print(str(alg))
|
print('{} ({})\n'.format(alg.displayName(), alg.id()))
|
||||||
algorithmOptions(id)
|
print(alg.shortHelpString())
|
||||||
|
print('\n----------------')
|
||||||
|
print('Input parameters')
|
||||||
|
print('----------------')
|
||||||
|
for p in alg.parameterDefinitions():
|
||||||
|
print('\n{}: <{}>'.format(p.name(), p.__class__.__name__))
|
||||||
|
if p.description():
|
||||||
|
print('\t' + p.description())
|
||||||
|
|
||||||
|
if isinstance(p, QgsProcessingParameterEnum):
|
||||||
|
opts = []
|
||||||
|
for i, o in enumerate(p.options()):
|
||||||
|
opts.append('\t\t{} - {}'.format(i, o))
|
||||||
|
print('\n'.join(opts))
|
||||||
|
|
||||||
|
print('\n----------------')
|
||||||
|
print('Outputs')
|
||||||
|
print('----------------')
|
||||||
|
|
||||||
|
for o in alg.outputDefinitions():
|
||||||
|
print('\n{}: <{}>'.format(o.name(), o.__class__.__name__))
|
||||||
|
if o.description():
|
||||||
|
print('\t' + o.description())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('Algorithm "{}" not found.'.format(id))
|
print('Algorithm "{}" not found.'.format(id))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user