本文整理汇总了Python中processing.script.ScriptAlgorithm.ScriptAlgorithm.getOutputValuesAsDictionary方法的典型用法代码示例。如果您正苦于以下问题:Python ScriptAlgorithm.getOutputValuesAsDictionary方法的具体用法?Python ScriptAlgorithm.getOutputValuesAsDictionary怎么用?Python ScriptAlgorithm.getOutputValuesAsDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.script.ScriptAlgorithm.ScriptAlgorithm
的用法示例。
在下文中一共展示了ScriptAlgorithm.getOutputValuesAsDictionary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_algorithm
# 需要导入模块: from processing.script.ScriptAlgorithm import ScriptAlgorithm [as 别名]
# 或者: from processing.script.ScriptAlgorithm.ScriptAlgorithm import getOutputValuesAsDictionary [as 别名]
def check_algorithm(self, name, defs):
"""
Will run an algorithm definition and check if it generates the expected result
:param name: The identifier name used in the test output heading
:param defs: A python dict containing a test algorithm definition
"""
QgsProject.instance().removeAllMapLayers()
params = self.load_params(defs['params'])
if defs['algorithm'].startswith('script:'):
filePath = os.path.join(processingTestDataPath(), 'scripts', '{}.py'.format(defs['algorithm'][len('script:'):]))
alg = ScriptAlgorithm(filePath)
else:
alg = QgsApplication.processingRegistry().algorithmById(defs['algorithm'])
if isinstance(params, list):
for param in zip(alg.parameters, params):
param[0].setValue(param[1])
else:
for k, p in list(params.items()):
alg.setParameterValue(k, p)
for r, p in list(defs['results'].items()):
alg.setOutputValue(r, self.load_result_param(p))
expectFailure = False
if 'expectedFailure' in defs:
exec(('\n'.join(defs['expectedFailure'][:-1])), globals(), locals())
expectFailure = eval(defs['expectedFailure'][-1])
if expectFailure:
try:
alg.execute()
self.check_results(alg.getOutputValuesAsDictionary(), defs['params'], defs['results'])
except Exception:
pass
else:
raise _UnexpectedSuccess
else:
alg.execute()
self.check_results(alg.getOutputValuesAsDictionary(), defs['params'], defs['results'])