Skip to content

Commit

Permalink
Set cell_number to 0 if history is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelq committed Oct 20, 2022
1 parent e91796d commit fb538e8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,15 @@ def to_mimebundle(self, fig_dict):
return {"text/html": iframe_html}

def build_filename(self):
ip = IPython.get_ipython() if IPython else None
cell_number = list(ip.history_manager.get_tail(1))[0][1] + 1 if ip else 0
filename = "{dirname}/figure_{cell_number}.html".format(
if IPython:
ip = IPython.get_ipython()
cell_number = next(ip.history_manager.get_tail(1), (0, -1, ""))[1] + 1
else:
cell_number = 0

return "{dirname}/figure_{cell_number}.html".format(
dirname=self.html_directory, cell_number=cell_number
)
return filename

def build_url(self, filename):
return filename
Expand Down

0 comments on commit fb538e8

Please sign in to comment.