40
40
41
41
from qgis .core import QgsExpressionContext , QgsExpressionContextUtils , QgsExpression , QgsExpressionContextScope
42
42
43
+
43
44
def _expressionContext (alg ):
44
45
context = QgsExpressionContext ()
45
46
context .appendScope (QgsExpressionContextUtils .globalScope ())
@@ -50,6 +51,7 @@ def _expressionContext(alg):
50
51
context .appendScope (processingScope )
51
52
return context
52
53
54
+
53
55
class Output (object ):
54
56
55
57
def __init__ (self , name = '' , description = '' , hidden = False ):
@@ -93,17 +95,17 @@ def setValue(self, value):
93
95
return True
94
96
except :
95
97
return False
96
-
98
+
97
99
def _resolveTemporary (self , alg ):
98
100
ext = self .getDefaultFileExtension ()
99
101
return getTempFilenameInTempFolder (self .name + '.' + ext )
100
-
102
+
101
103
def _supportedExtensions (self ):
102
104
return []
103
-
105
+
104
106
def resolveValue (self , alg ):
105
107
if not self .hidden and not bool (self .value ):
106
- self .value = self ._resolveTemporary (alg )
108
+ self .value = self ._resolveTemporary (alg )
107
109
else :
108
110
exp = QgsExpression (self .value )
109
111
if not exp .hasParserError ():
@@ -113,7 +115,7 @@ def resolveValue(self, alg):
113
115
114
116
if ":" not in self .value :
115
117
if not os .path .isabs (self .value ):
116
- self .value = os .path .join (ProcessingConfig .getSetting (ProcessingConfig .OUTPUT_FOLDER ),
118
+ self .value = os .path .join (ProcessingConfig .getSetting (ProcessingConfig .OUTPUT_FOLDER ),
117
119
self .value )
118
120
supported = self ._supportedExtensions ()
119
121
if supported :
@@ -138,7 +140,7 @@ def tr(self, string, context=''):
138
140
139
141
140
142
class OutputDirectory (Output ):
141
-
143
+
142
144
def resolveValue (self , alg ):
143
145
self .value = getTempDirInTempFolder ()
144
146
@@ -330,7 +332,6 @@ def getDefaultFileExtension(self):
330
332
default = 'dbf'
331
333
return default
332
334
333
-
334
335
def getCompatibleFileName (self , alg ):
335
336
"""Returns a filename that is compatible with the algorithm
336
337
that is going to generate this output.
@@ -389,7 +390,7 @@ def _resolveTemporary(self, alg):
389
390
else :
390
391
ext = self .getDefaultFileExtension ()
391
392
return getTempFilenameInTempFolder (self .name + '.' + ext )
392
-
393
+
393
394
394
395
def getOutputFromString (s ):
395
396
try :
@@ -402,7 +403,7 @@ def getOutputFromString(s):
402
403
tokens = s .split ("=" )
403
404
token = tokens [1 ].strip ()[len ('output' ) + 1 :]
404
405
out = None
405
-
406
+
406
407
if token .lower ().strip ().startswith ('raster' ):
407
408
out = OutputRaster ()
408
409
elif token .lower ().strip () == 'vector' :
@@ -430,7 +431,7 @@ def getOutputFromString(s):
430
431
out = OutputString ()
431
432
elif token .lower ().strip ().startswith ('extent' ):
432
433
out = OutputExtent ()
433
-
434
+
434
435
return out
435
436
except :
436
- return None
437
+ return None
0 commit comments