From 9c2721b08b02641ab4c61f97f710aa6347b94c15 Mon Sep 17 00:00:00 2001 From: volaya Date: Sat, 28 May 2016 16:25:35 +0200 Subject: [PATCH] =?UTF-8?q?[processing]=20added=20=E2=80=98supported?= =?UTF-8?q?=E2=80=99=20parameter=20to=20exportVectorLayer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/plugins/processing/algs/gdal/GdalAlgorithm.py | 3 ++- python/plugins/processing/tools/dataobjects.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/plugins/processing/algs/gdal/GdalAlgorithm.py b/python/plugins/processing/algs/gdal/GdalAlgorithm.py index 7dec6cdadf2..67aee8a2f01 100644 --- a/python/plugins/processing/algs/gdal/GdalAlgorithm.py +++ b/python/plugins/processing/algs/gdal/GdalAlgorithm.py @@ -50,10 +50,11 @@ class GdalAlgorithm(GeoAlgorithm): def processAlgorithm(self, progress): commands = self.getConsoleCommands() layers = dataobjects.getVectorLayers() + supported = dataobjects.getSupportedOutputVectorLayerExtensions() for i, c in enumerate(commands): for layer in layers: if layer.source() in c: - c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer)) + c = c.replace(layer.source(), dataobjects.exportVectorLayer(layer, supported)) commands[i] = c GdalUtils.runGdal(commands, progress) diff --git a/python/plugins/processing/tools/dataobjects.py b/python/plugins/processing/tools/dataobjects.py index 2e59a03ecc9..9368259729d 100644 --- a/python/plugins/processing/tools/dataobjects.py +++ b/python/plugins/processing/tools/dataobjects.py @@ -271,7 +271,7 @@ def getObjectFromUri(uri, forceLoad=True): return None -def exportVectorLayer(layer): +def exportVectorLayer(layer, supported=None): """Takes a QgsVectorLayer and returns the filename to refer to it, which allows external apps which support only file-based layers to use it. It performs the necessary export in case the input layer @@ -285,6 +285,7 @@ def exportVectorLayer(layer): a new file if the original one contains non-ascii characters. """ + supported = supported or ["shp"] settings = QSettings() systemEncoding = settings.value('/UI/encoding', 'System') @@ -317,7 +318,7 @@ def exportVectorLayer(layer): unicode(layer.source()).decode('ascii') except UnicodeEncodeError: isASCII = False - if not unicode(layer.source()).endswith('shp') or not isASCII: + if not os.path.splitext()[1] in supported or not isASCII: writer = QgsVectorFileWriter( output, systemEncoding, layer.pendingFields(), provider.geometryType(),