|
61 | 61 | QgsProcessingParameterFile,
|
62 | 62 | QgsProcessingParameterFolderDestination,
|
63 | 63 | QgsProcessingOutputHtml,
|
64 |
| - QgsProcessingUtils, |
65 | 64 | QgsVectorLayer,
|
66 | 65 | QgsProviderRegistry)
|
67 | 66 | from qgis.utils import iface
|
|
73 | 72 |
|
74 | 73 | from .Grass7Utils import Grass7Utils
|
75 | 74 |
|
76 |
| -#from processing.tools import dataobjects, system |
77 | 75 | from processing.tools.system import isWindows, getTempFilename
|
78 | 76 |
|
79 | 77 | pluginPath = os.path.normpath(os.path.join(
|
@@ -187,7 +185,7 @@ def initAlgorithm(self, config=None):
|
187 | 185 | """
|
188 | 186 | for p in self.params:
|
189 | 187 | # We use createOutput argument for automatic output creation
|
190 |
| - res = self.addParameter(p, True) |
| 188 | + self.addParameter(p, True) |
191 | 189 |
|
192 | 190 | def defineCharacteristicsFromFile(self):
|
193 | 191 | """
|
@@ -441,7 +439,7 @@ def processInputs(self, parameters, context, feedback):
|
441 | 439 | QgsProcessingParameterMultipleLayers))]
|
442 | 440 | for param in inputs:
|
443 | 441 | paramName = param.name()
|
444 |
| - if not paramName in parameters: |
| 442 | + if paramName not in parameters: |
445 | 443 | continue
|
446 | 444 | # Handle Null parameter
|
447 | 445 | if parameters[paramName] is None:
|
@@ -640,7 +638,6 @@ def processCommand(self, parameters, context, feedback, delOutputs=False):
|
640 | 638 | if outName in parameters and parameters[outName] is not None:
|
641 | 639 | # We add an output name to make sure it is unique if the session
|
642 | 640 | # uses this algorithm several times.
|
643 |
| - #value = self.parameterAsOutputLayer(parameters, outName, context) |
644 | 641 | uniqueOutputName = outName + self.uniqueSuffix
|
645 | 642 | command += ' {}={}'.format(outName, uniqueOutputName)
|
646 | 643 |
|
@@ -669,7 +666,7 @@ def processOutputs(self, parameters, context, feedback):
|
669 | 666 |
|
670 | 667 | for out in self.destinationParameterDefinitions():
|
671 | 668 | outName = out.name()
|
672 |
| - if not outName in parameters: |
| 669 | + if outName not in parameters: |
673 | 670 | # skipped output
|
674 | 671 | continue
|
675 | 672 |
|
@@ -785,15 +782,22 @@ def exportRasterLayersIntoDirectory(self, name, parameters, context, colorTable=
|
785 | 782 |
|
786 | 783 | # Add a loop export from the basename
|
787 | 784 | for cmd in [self.commands, self.outputCommands]:
|
788 |
| - # TODO Windows support |
789 | 785 | # TODO Format/options support
|
790 |
| - cmd.append("for r in $(g.list type=rast pattern='{}*'); do".format(basename)) |
791 |
| - cmd.append(" r.out.gdal -m{0} input=${{r}} output={1}/${{r}}.tif {2}".format( |
792 |
| - ' -t' if colorTable else '', outDir, |
793 |
| - '--overwrite -c createopt="TFW=YES,COMPRESS=LZW"' |
794 |
| - ) |
795 |
| - ) |
796 |
| - cmd.append("done") |
| 786 | + if isWindows(): |
| 787 | + cmd.append("if not exist {0} mkdir {0}".format(outDir)) |
| 788 | + cmd.append("for /F %%r IN ('g.list type^=rast pattern^=\"{0}*\"') do r.out.gdal -m{1} input=%%r output={2}/%%r.tif {3}".format( |
| 789 | + basename, |
| 790 | + ' -t' if colorTable else '', |
| 791 | + outDir, |
| 792 | + '--overwrite -c createopt="TFW=YES,COMPRESS=LZW"' |
| 793 | + )) |
| 794 | + else: |
| 795 | + cmd.append("for r in $(g.list type=rast pattern='{}*'); do".format(basename)) |
| 796 | + cmd.append(" r.out.gdal -m{0} input=${{r}} output={1}/${{r}}.tif {2}".format( |
| 797 | + ' -t' if colorTable else '', outDir, |
| 798 | + '--overwrite -c createopt="TFW=YES,COMPRESS=LZW"' |
| 799 | + )) |
| 800 | + cmd.append("done") |
797 | 801 |
|
798 | 802 | def loadVectorLayerFromParameter(self, name, parameters, context, feedback, external=False):
|
799 | 803 | """
|
@@ -999,7 +1003,6 @@ def setSessionProjectionFromLayer(self, layer):
|
999 | 1003 | def convertToHtml(self, fileName):
|
1000 | 1004 | # Read HTML contents
|
1001 | 1005 | lines = []
|
1002 |
| - html = False |
1003 | 1006 | with open(fileName, 'r', encoding='utf-8') as f:
|
1004 | 1007 | lines = f.readlines()
|
1005 | 1008 |
|
|
0 commit comments