Skip to content

Commit 9c2721b

Browse files
committed
[processing] added ‘supported’ parameter to exportVectorLayer
1 parent ebf4340 commit 9c2721b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

python/plugins/processing/algs/gdal/GdalAlgorithm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ def getCustomParametersDialog(self):
5050
def processAlgorithm(self, progress):
5151
commands = self.getConsoleCommands()
5252
layers = dataobjects.getVectorLayers()
53+
supported = dataobjects.getSupportedOutputVectorLayerExtensions()
5354
for i, c in enumerate(commands):
5455
for layer in layers:
5556
if layer.source() in c:
56-
c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer))
57+
c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer, supported))
5758

5859
commands[i] = c
5960
GdalUtils.runGdal(commands, progress)

python/plugins/processing/tools/dataobjects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def getObjectFromUri(uri, forceLoad=True):
271271
return None
272272

273273

274-
def exportVectorLayer(layer):
274+
def exportVectorLayer(layer, supported=None):
275275
"""Takes a QgsVectorLayer and returns the filename to refer to it,
276276
which allows external apps which support only file-based layers to
277277
use it. It performs the necessary export in case the input layer
@@ -285,6 +285,7 @@ def exportVectorLayer(layer):
285285
a new file if the original one contains non-ascii characters.
286286
"""
287287

288+
supported = supported or ["shp"]
288289
settings = QSettings()
289290
systemEncoding = settings.value('/UI/encoding', 'System')
290291

@@ -317,7 +318,7 @@ def exportVectorLayer(layer):
317318
unicode(layer.source()).decode('ascii')
318319
except UnicodeEncodeError:
319320
isASCII = False
320-
if not unicode(layer.source()).endswith('shp') or not isASCII:
321+
if not os.path.splitext()[1] in supported or not isASCII:
321322
writer = QgsVectorFileWriter(
322323
output, systemEncoding,
323324
layer.pendingFields(), provider.geometryType(),

0 commit comments

Comments
 (0)