Added strict class attribute to OptsMagic
import time
+import sys
from collections import defaultdict
try:
@@ -617,6 +618,7 @@ class OptsMagic(Magics):
"""
error_message = None # If not None, the error message that will be displayed
opts_spec = None # Next id to propagate, binding displayed object together.
+ strict = False
@classmethod
def process_element(cls, obj):
@@ -628,7 +630,10 @@ class OptsMagic(Magics):
normal.
"""
if cls.error_message:
+ if cls.strict:
return cls.error_message
+ else:
+ sys.stderr.write(cls.error_message.replace('<br>','\n'))
if cls.opts_spec is not None:
StoreOptions.set_options(obj, cls.opts_spec)
cls.opts_spec = None
@@ -677,7 +682,6 @@ class OptsMagic(Magics):
StoreOptions.validate_spec(spec)
except OptionError as e:
cls.error_message = cls._format_options_error(e)
- return None
cls.opts_spec = spec
@@ -753,6 +757,8 @@ class OptsMagic(Magics):
except OptionError as e:
OptsMagic.error_message = None
display(HTML(self._format_options_error(e)))
+ if self.strict:
+ display(HTML('Options specification will not be applied.'))
return
with options_policy(skip_invalid=True, warn_on_skip=False):
