Skip to content

Commit a65e9cf

Browse files
committed
Change to pathlib read/write methods
1 parent 57f2353 commit a65e9cf

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

jupyter_sphinx/execute.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ def write_notebook_output(notebook, output_dir, notebook_name, location=None):
270270

271271
notebook_file = notebook_name + ext
272272
output_dir = Path(output_dir)
273-
with (output_dir / notebook_file).open("w", encoding = "utf8") as f:
274-
f.write(contents)
273+
(output_dir / notebook_file).write_text(contents, encoding = "utf8")
275274

276275

277276
def contains_widgets(notebook):

jupyter_sphinx/thebelab.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,13 @@ def add_thebelab_library(doctree, env):
9797
js.logger.warning("The supplied thebelab configuration file does not exist")
9898
return
9999

100-
with filename.open("r") as config_file:
101-
try:
102-
thebe_config = json.load(config_file)
103-
except ValueError:
104-
js.logger.warning(
105-
"The supplied thebelab configuration file is not in JSON format."
106-
)
107-
return
100+
try:
101+
thebe_config = json.load(filename.read_bytes())
102+
except ValueError:
103+
js.logger.warning(
104+
"The supplied thebelab configuration file is not in JSON format."
105+
)
106+
return
108107
else:
109108
js.logger.warning(
110109
"The supplied thebelab configuration should be either a filename or a dictionary."

0 commit comments

Comments
 (0)