Skip to content

Commit

Permalink
Remove exception which is never raised
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 5, 2020
1 parent 9ba699e commit 0fff933
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
Expand Up @@ -29,7 +29,6 @@
from qgis.core import QgsApplication, QgsSettings, QgsProcessingModelAlgorithm

from processing.gui.ToolboxAction import ToolboxAction
from processing.modeler.exceptions import WrongModelException
from processing.modeler.ModelerUtils import ModelerUtils

pluginPath = os.path.split(os.path.dirname(__file__))[0]
Expand Down
30 changes: 11 additions & 19 deletions python/plugins/processing/modeler/ModelerAlgorithmProvider.py
Expand Up @@ -23,15 +23,11 @@

import os

from qgis.PyQt.QtXml import QDomDocument

from qgis.core import (Qgis,
QgsApplication,
QgsProcessingProvider,
QgsMessageLog,
QgsProcessingModelAlgorithm,
QgsProcessingUtils,
QgsXmlUtils)
QgsProcessingModelAlgorithm)

from processing.core.ProcessingConfig import ProcessingConfig, Setting

Expand All @@ -45,7 +41,6 @@
from processing.modeler.EditModelAction import EditModelAction
from processing.modeler.ExportModelAsPythonScriptAction import ExportModelAsPythonScriptAction
from processing.modeler.OpenModelFromFileAction import OpenModelFromFileAction
from processing.modeler.exceptions import WrongModelException
from processing.modeler.ModelerUtils import ModelerUtils

pluginPath = os.path.split(os.path.dirname(__file__))[0]
Expand Down Expand Up @@ -120,17 +115,14 @@ def loadFromFolder(self, folder):
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('model3'):
try:
fullpath = os.path.join(path, descriptionFile)

alg = QgsProcessingModelAlgorithm()
if alg.fromFile(fullpath):
if alg.name():
alg.setSourceFilePath(fullpath)
self.algs.append(alg)
else:
QgsMessageLog.logMessage(self.tr('Could not load model {0}', 'ModelerAlgorithmProvider').format(descriptionFile),
self.tr('Processing'), Qgis.Critical)
except WrongModelException as e:
QgsMessageLog.logMessage(self.tr('Could not load model {0}\n{1}', 'ModelerAlgorithmProvider').format(descriptionFile, str(e)),
fullpath = os.path.join(path, descriptionFile)

alg = QgsProcessingModelAlgorithm()
if alg.fromFile(fullpath):
if alg.name():
alg.setSourceFilePath(fullpath)
self.algs.append(alg)
else:
QgsMessageLog.logMessage(self.tr('Could not load model {0}', 'ModelerAlgorithmProvider').format(descriptionFile),
self.tr('Processing'), Qgis.Critical)

4 changes: 0 additions & 4 deletions python/plugins/processing/modeler/exceptions.py
Expand Up @@ -18,9 +18,5 @@
"""


class WrongModelException(Exception):
pass


class UndefinedParameterException(Exception):
pass

0 comments on commit 0fff933

Please sign in to comment.