Skip to content

Commit

Permalink
[processing] multiple band selection wrapper should return list of ints
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Sep 4, 2018
1 parent 1664ef1 commit 97adef2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 1 addition & 4 deletions python/plugins/processing/algs/gdal/rearrange_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

bands = self.parameterAsFields(parameters, self.BANDS, context)
for band in bands:
match = re.search('(?:\A|[^0-9])([0-9]+)(?:\Z|[^0-9]|)', band)
if match:
band_nb = match.group(1)
arguments.append('-b {}'.format(band_nb))
arguments.append('-b {}'.format(band))

arguments.append('-ot')
arguments.append(self.TYPES[self.parameterAsEnum(parameters, self.DATA_TYPE, context)])
Expand Down
14 changes: 9 additions & 5 deletions python/plugins/processing/gui/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import locale
import os
import re
from functools import cmp_to_key
from inspect import isclass
from copy import deepcopy
Expand Down Expand Up @@ -1726,10 +1727,8 @@ def setValue(self, value):

for v in value:
for i, opt in enumerate(options):
if opt == v:
selected.append(i)
# case insensitive check - only do if matching case value is not present
elif v not in options and opt.lower() == v.lower():
match = re.search('(?:\A|[^0-9]){}(?:\Z|[^0-9]|)'.format(v), opt)
if match:
selected.append(i)

self.widget.setSelectedItems(selected)
Expand All @@ -1741,7 +1740,12 @@ def setValue(self, value):
def value(self):
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
if self.param.allowMultiple():
return [self.widget.options[i] for i in self.widget.selectedoptions]
bands = []
for i in self.widget.selectedoptions:
match = re.search('(?:\A|[^0-9])([0-9]+)(?:\Z|[^0-9]|)', self.widget.options[i])
if match:
bands.append(match.group(1))
return bands
else:
f = self.widget.currentBand()
if self.param.flags() & QgsProcessingParameterDefinition.FlagOptional and not f:
Expand Down

0 comments on commit 97adef2

Please sign in to comment.