Skip to content
Permalink
Browse files

Make html output in basic stats algorithm optional

  • Loading branch information
nyalldawson committed Jun 11, 2017
1 parent cb41ef1 commit e49cc786740d99748921c12fb9a92b7e6892043c
@@ -94,7 +94,7 @@ def __init__(self):
self.tr('Field to calculate statistics on'),
None, self.INPUT_LAYER, QgsProcessingParameterTableField.Any))

self.addParameter(QgsProcessingParameterFileOutput(self.OUTPUT_HTML_FILE, self.tr('Statistics'), self.tr('HTML files (*.html)')))
self.addParameter(QgsProcessingParameterFileOutput(self.OUTPUT_HTML_FILE, self.tr('Statistics'), self.tr('HTML files (*.html)'), None, True))
self.addOutput(QgsProcessingOutputHtml(self.OUTPUT_HTML_FILE, self.tr('Statistics')))

self.addOutput(QgsProcessingOutputNumber(self.COUNT, self.tr('Count')))
@@ -149,9 +149,10 @@ def processAlgorithm(self, parameters, context, feedback):
d, results = self.calcStringStats(features, feedback, field, count)
data.extend(d)

self.createHTML(output_file, data)
if output_file:
self.createHTML(output_file, data)
results[self.OUTPUT_HTML_FILE] = output_file

results[self.OUTPUT_HTML_FILE] = output_file
return results

def calcNumericStats(self, features, feedback, field, count):
@@ -91,6 +91,7 @@ def textChanged(self):

def skipOutput(self):
self.leText.setPlaceholderText(self.SKIP_OUTPUT)
self.leText.setText('')
self.use_temporary = False

def selectOutput(self):
@@ -99,8 +100,7 @@ def selectOutput(self):
else:
popupMenu = QMenu()

if isinstance(self.parameter, QgsProcessingParameterFeatureSink) \
and self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
if self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
actionSkipOutput = QAction(
self.tr('Skip output'), self.btnSelect)
actionSkipOutput.triggered.connect(self.skipOutput)

0 comments on commit e49cc78

Please sign in to comment.
You can’t perform that action at this time.