def checkOutputFileExtensions(self): """Checks if the values of outputs are correct and have one of the supported output extensions. If not, it adds the first one of the supported extensions, which is assumed to be the default one. """ for out in self.outputs: if not out.hidden and out.value is not None: if not os.path.isabs(out.value): continue if isinstance(out, OutputRaster): exts = \ dataobjects.getSupportedOutputRasterLayerExtensions() elif isinstance(out, OutputVector): exts = \ dataobjects.getSupportedOutputVectorLayerExtensions() elif isinstance(out, OutputTable): exts = dataobjects.getSupportedOutputTableExtensions() elif isinstance(out, OutputHTML): exts = ['html', 'htm'] else: continue idx = out.value.rfind('.') if idx == -1: out.value = out.value + '.' + exts[0] else: ext = out.value[idx + 1:] if ext not in exts: out.value = out.value + '.' + exts[0]
def checkOutputFileExtensions(self): """Checks if the values of outputs are correct and have one of the supported output extensions. If not, it adds the first one of the supported extensions, which is assumed to be the default one. """ for out in self.outputs: if not out.hidden and out.value is not None: if not os.path.isabs(out.value): continue if isinstance(out, OutputRaster): exts = dataobjects.getSupportedOutputRasterLayerExtensions() elif isinstance(out, OutputVector): exts = dataobjects.getSupportedOutputVectorLayerExtensions() elif isinstance(out, OutputTable): exts = dataobjects.getSupportedOutputTableExtensions() elif isinstance(out, OutputHTML): exts = ["html", "htm"] else: continue idx = out.value.rfind(".") if idx == -1: out.value = out.value + "." + exts[0] else: ext = out.value[idx + 1 :] if ext not in exts: out.value = out.value + "." + exts[0]
def getFileFilter(self): if self.datatype == ParameterMultipleInput.TYPE_RASTER: exts = dataobjects.getSupportedOutputRasterLayerExtensions() else: exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = exts[i].upper() + ' files(*.' + exts[i].lower() + ')' return ';;'.join(exts)
def getSupportedOutputVectorLayerExtensions(self): exts = dataobjects.getSupportedOutputVectorLayerExtensions() if not self.hasGeometry(): exts = ['dbf'] + [ ext for ext in exts if ext in VectorWriter.nogeometry_extensions ] return exts
def getFileFilter(self): if self.datatype == ParameterMultipleInput.TYPE_RASTER: exts = dataobjects.getSupportedOutputRasterLayerExtensions() elif self.datatype == ParameterMultipleInput.TYPE_FILE: return self.tr('All files (*.*)', 'ParameterMultipleInput') else: exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = self.tr('%s files(*.%s)', 'ParameterMultipleInput') % (exts[i].upper(), exts[i].lower()) return ';;'.join(exts)
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, supported)) commands[i] = c GdalUtils.runGdal(commands, progress)
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, supported)) commands[i] = c GdalUtils.runGdal(commands, progress)
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: exported = dataobjects.exportVectorLayer(layer, supported) exportedFileName = os.path.splitext(os.path.split(exported)[1])[0] c = c.replace(layer.source(), exported) if os.path.isfile(layer.source()): fileName = os.path.splitext(os.path.split(layer.source())[1])[0] c = c.replace(fileName, exportedFileName) commands[i] = c GdalUtils.runGdal(commands, progress)
def processAlgorithm(self, feedback): commands = self.getConsoleCommands() layers = dataobjects.getVectorLayers() supported = dataobjects.getSupportedOutputVectorLayerExtensions() for i, c in enumerate(commands): for layer in layers: if layer.source() in c: exported = dataobjects.exportVectorLayer(layer, supported) exportedFileName = os.path.splitext(os.path.split(exported)[1])[0] c = c.replace(layer.source(), exported) if os.path.isfile(layer.source()): fileName = os.path.splitext(os.path.split(layer.source())[1])[0] c = re.sub('[\s]{}[\s]'.format(fileName), ' ' + exportedFileName + ' ', c) c = re.sub('[\s]{}'.format(fileName), ' ' + exportedFileName, c) c = re.sub('["\']{}["\']'.format(fileName), "'" + exportedFileName + "'", c) commands[i] = c GdalUtils.runGdal(commands, feedback)
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: exported = dataobjects.exportVectorLayer(layer, supported) exportedFileName = os.path.splitext(os.path.split(exported)[1])[0] c = c.replace(layer.source(), exported) if os.path.isfile(layer.source()): fileName = os.path.splitext(os.path.split(layer.source())[1])[0] c = c.replace(' ' + fileName + ' ', ' ' + exportedFileName + ' ') commands[i] = c GdalUtils.runGdal(commands, progress) #workaround to stop the algorithm in order to check the log in case of error import time time.sleep(5)
def getSupportedOutputVectorLayerExtensions(self): return dataobjects.getSupportedOutputVectorLayerExtensions()
def getSupportedOutputVectorLayerExtensions(self): exts = dataobjects.getSupportedOutputVectorLayerExtensions() if not self.hasGeometry(): exts = ['dbf'] + [ext for ext in exts if ext in VectorWriter.nogeometry_extensions] return exts
def getFileFilter(self,alg): exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = exts[i].upper() + " files(*." + exts[i].lower() + ")" return ";;".join(exts)
def getFileFilter(self, alg): exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = exts[i].upper() + ' files(*.' + exts[i].lower() + ')' return ';;'.join(exts)
def getFileFilter(self): exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = self.tr("%s files(*.%s)", "ParameterVector") % (exts[i].upper(), exts[i].lower()) return ";;".join(exts)
def getFileFilter(self): exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = exts[i].upper() + ' files(*.' + exts[i].lower() + ')' return ';;'.join(exts)
def getFileFilter(self, alg): exts = dataobjects.getSupportedOutputVectorLayerExtensions() for i in range(len(exts)): exts[i] = self.tr('%s files (*.%s)', 'OutputVector') % (exts[i].upper(), exts[i].lower()) return ';;'.join(exts)