Skip to content

Commit

Permalink
hv.output can now warn if an object is supplied without a filename (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens authored and philippjfr committed Jun 15, 2017
1 parent 544c41e commit aecbbce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion holoviews/util/__init__.py
Expand Up @@ -118,8 +118,13 @@ class output(param.ParameterizedFunction):
are ignored.
"""

def __call__(self, *args, **options):
filename_warning = param.Boolean(default=True, doc="""
Whether to warn if the output utility is called on an object and
a filename is not given (in which case the utility has no
effect)""" )

def __call__(self, *args, **options):
warn = options.pop('filename_warning', self.filename_warning)
help_prompt = 'For help with hv.util.output call help(hv.util.output)'
line, obj = None,None
if len(args) > 2:
Expand All @@ -141,6 +146,9 @@ def __call__(self, *args, **options):
def save_fn(obj, renderer): renderer.save(obj, options['filename'])
Store.output_settings.output(line=line, cell=obj, cell_runner=save_fn,
help_prompt=help_prompt, **options)
elif warn:
self.warning("hv.output not supplied a filename to export the "
"given object. This call will have no effect." )
return obj
elif obj is not None:
return obj
Expand Down

0 comments on commit aecbbce

Please sign in to comment.