Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] qgis_process now supports running a Python script algorithm
directly by specifying the path to the .py file in place of an algorithm ID or model file path
- Loading branch information
1 parent
dde113d
commit d0718cb
Showing
6 changed files
with
164 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
from qgis.PyQt.QtCore import QCoreApplication | ||
from qgis.core import (QgsProcessing, | ||
QgsFeatureSink, | ||
QgsProcessingException, | ||
QgsProcessingAlgorithm, | ||
QgsProcessingParameterString, | ||
QgsProcessingOutputString) | ||
|
||
|
||
class ConvertStringToUppercase(QgsProcessingAlgorithm): | ||
INPUT = 'INPUT' | ||
OUTPUT = 'OUTPUT' | ||
|
||
def createInstance(self): | ||
return ConvertStringToUppercase() | ||
|
||
def name(self): | ||
return 'converttouppercase' | ||
|
||
def displayName(self): | ||
return 'Convert to upper' | ||
|
||
def shortDescription(self): | ||
return 'Converts a string to upper case' | ||
|
||
def initAlgorithm(self, config=None): | ||
self.addParameter( | ||
QgsProcessingParameterString( | ||
self.INPUT, | ||
'Input string' | ||
) | ||
) | ||
|
||
self.addOutput( | ||
QgsProcessingOutputString( | ||
self.OUTPUT, | ||
'Output string' | ||
) | ||
) | ||
|
||
def processAlgorithm(self, parameters, context, feedback): | ||
input_string = self.parameterAsString(parameters, self.INPUT, context) | ||
output_string = input_string.upper() | ||
feedback.pushInfo('Converted {} to {}'.format(input_string, output_string)) | ||
return {self.OUTPUT: output_string} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
print('a') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
if 1==: | ||
|