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 30, 2022
1 parent ec808fe commit 4f6201b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,14 @@ def to_mimebundle(self, fig_dict):

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 ip:
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 4f6201b

Please sign in to comment.