Skip to content

Commit

Permalink
[processing] added ‘supported’ parameter to exportVectorLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed May 30, 2016
1 parent ebf4340 commit 9c2721b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -50,10 +50,11 @@ def getCustomParametersDialog(self):
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)
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/tools/dataobjects.py
Expand Up @@ -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
Expand All @@ -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')

Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 9c2721b

Please sign in to comment.