Skip to content

Commit

Permalink
Updated _format_options_error method of OptsMagic
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Apr 13, 2017
1 parent 5bf8fc5 commit 455d2bd
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions holoviews/ipython/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,34 @@ def process_element(cls, obj):

@classmethod
def _format_options_error(cls, err):
info = (err.invalid_keyword, ', '.join(err.allowed_keywords))
return "Keyword <b>%r</b> not supported by any of the loaded backends. Valid options are :<br><br><b>%s</b>" % info
"""
Return a fuzzy match message string based on the supplied OptionError
"""
allowed_keywords = err.allowed_keywords
target = allowed_keywords.target
matches = allowed_keywords.fuzzy_match(err.invalid_keyword)
if not matches:
matches = allowed_keywords.values
similarity = 'Possible'
else:
similarity = 'Similar'

loaded_backends = Store.loaded_backends()
target = 'for {0}'.format(target) if target else ''

if len(loaded_backends) == 1:
loaded=' in loaded backend {0!r}'.format(loaded_backends[0])
else:
backend_list = ', '.join(['%r'% b for b in loaded_backends[:-1]])
loaded=' in loaded backends {0} and {1!r}'.format(backend_list,
loaded_backends[-1])

msg=('Unexpected keyword {kw} {target}{loaded}.<br><br>'
'{similarity} keywords in the currently active '
'{current_backend} backend are: {matches}')
return msg.format(kw="'%s'" % err.invalid_keyword, target=target,
loaded=loaded, similarity=similarity,
current_backend=repr(Store.current_backend), matches=matches)

@classmethod
def register_custom_spec(cls, spec):
Expand Down

0 comments on commit 455d2bd

Please sign in to comment.