Skip to content

Commit

Permalink
Python 2 iframe renderer follow-on to #1809 (#1822)
Browse files Browse the repository at this point in the history
* Revert back to makedirs with exist_ok in codegen since this is already Python 3 only
* Follow the Python 3 makedirs implementation by checking isdir rather than errno
  • Loading branch information
jonmmease authored Oct 16, 2019
1 parent d7021e8 commit d43331a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions packages/python/plotly/codegen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ def write_source_py(py_source, filepath, leading_newlines=0):
# Make dir if needed
# ------------------
filedir = opath.dirname(filepath)
try:
os.makedirs(filedir)
except OSError as error:
if error.errno != errno.EEXIST:
raise
# The exist_ok kwarg is only supported with Python 3, but that's ok since
# codegen is only supported with Python 3 anyway
os.makedirs(filedir, exist_ok=True)

# Write file
# ----------
Expand Down
4 changes: 2 additions & 2 deletions packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import webbrowser
import inspect
import os
import errno
from os.path import isdir

import six
from plotly.io import to_json, to_image, write_image, write_html
Expand Down Expand Up @@ -568,7 +568,7 @@ def to_mimebundle(self, fig_dict):
try:
os.makedirs(self.html_directory)
except OSError as error:
if error.errno != errno.EEXIST:
if not isdir(self.html_directory):
raise

write_html(
Expand Down

0 comments on commit d43331a

Please sign in to comment.