Skip to content

Commit

Permalink
Added try except blocks around each filter import in ExamplePlugin
Browse files Browse the repository at this point in the history
* If one filter has a syntax error it now does not prevent the rest
of the plugin from loading. Most useful for plugin development

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ authored and imikejackson committed Apr 4, 2024
1 parent 7bdab07 commit 1c8f8c0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
34 changes: 28 additions & 6 deletions wrapping/python/plugins/ExamplePlugin/Plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@
Insert documentation here.
"""

from ExamplePlugin.ExampleFilter1 import ExampleFilter1
from ExamplePlugin.ExampleFilter2 import ExampleFilter2
from ExamplePlugin.CreateArray import CreateArrayFilter
from ExamplePlugin.InitializeData import InitializeDataPythonFilter
from ExamplePlugin.TemplateFilter import TemplateFilter
_filters = []

try:
from ExamplePlugin.ExampleFilter1 import ExampleFilter1
_filters.append(ExampleFilter1)
except ImportError:
pass
try:
from ExamplePlugin.ExampleFilter2 import ExampleFilter2
_filters.append(ExampleFilter2)
except ImportError:
pass
try:
from ExamplePlugin.CreateArray import CreateArrayFilter
_filters.append(CreateArrayFilter)
except ImportError:
pass
try:
from ExamplePlugin.InitializeData import InitializeDataPythonFilter
_filters.append(InitializeDataPythonFilter)
except ImportError:
pass
try:
from ExamplePlugin.TemplateFilter import TemplateFilter
_filters.append(TemplateFilter)
except ImportError:
pass

# FILTER_INCLUDE_INSERT

Expand All @@ -30,4 +52,4 @@ def vendor(self) -> str:
return 'Description'

def get_filters(self):
return [ExampleFilter1,ExampleFilter2,CreateArrayFilter,InitializeDataPythonFilter,TemplateFilter] # FILTER_NAME_INSERT
return _filters # FILTER_NAME_INSERT
35 changes: 27 additions & 8 deletions wrapping/python/plugins/ExamplePlugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
from ExamplePlugin.Plugin import ExamplePlugin

from ExamplePlugin.ExampleFilter1 import ExampleFilter1
from ExamplePlugin.ExampleFilter2 import ExampleFilter2
from ExamplePlugin.CreateArray import CreateArrayFilter
from ExamplePlugin.InitializeData import InitializeDataPythonFilter
from ExamplePlugin.TemplateFilter import TemplateFilter
__all__ = ['ExamplePlugin', 'get_plugin']

try:
from ExamplePlugin.ExampleFilter1 import ExampleFilter1
__all__.append('ExampleFilter1')
except ImportError:
pass
try:
from ExamplePlugin.ExampleFilter2 import ExampleFilter2
__all__.append('ExampleFilter2')
except ImportError:
pass
try:
from ExamplePlugin.CreateArray import CreateArrayFilter
__all__.append('CreateArrayFilter')
except ImportError:
pass
try:
from ExamplePlugin.InitializeData import InitializeDataPythonFilter
__all__.append('InitializeDataPythonFilter')
except ImportError:
pass
try:
from ExamplePlugin.TemplateFilter import TemplateFilter
__all__.append('TemplateFilter')
except ImportError:
pass

# FILTER_INCLUDE_INSERT

def get_plugin():
return ExamplePlugin()

__all__ = ['ExamplePlugin','ExampleFilter1', 'ExampleFilter2', 'CreateArrayFilter', 'InitializeDataPythonFilter', 'TemplateFilter', 'get_plugin'] # FILTER_NAME_INSERT

0 comments on commit 1c8f8c0

Please sign in to comment.