From 8d39969eaddfc6dccd64e2a29c6d83708816f24b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Tahavori <50955527+mohammadamint@users.noreply.github.com> Date: Sat, 2 Dec 2023 00:31:54 +0100 Subject: [PATCH] Apply suggestions from code review replacing f"{}/{}" with ps.path.join Co-authored-by: Pierre Francois --- docs/notebooks_convert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/notebooks_convert.py b/docs/notebooks_convert.py index c2295294..6b47812a 100644 --- a/docs/notebooks_convert.py +++ b/docs/notebooks_convert.py @@ -20,7 +20,7 @@ def convert_notebook_to_rst(input_file, output_dir, file_name): if not os.path.exists(output_dir): os.mkdir(output_dir) - output_file = f"{output_dir}/{file_name}.rst" + output_file = os.path.join(output_dir, f"{{file_name}.rst") # Write RST content to the output file with open(output_file, "w", encoding="utf-8") as f: @@ -31,7 +31,7 @@ def convert_notebook_to_rst(input_file, output_dir, file_name): # Copy images to the output folder image_dir = output_dir for image_filename, image_data in resources["outputs"].items(): - image_path = f"{output_dir}/{image_filename}" + image_path = os.path,join(output_dir, image_filename) with open(image_path, "wb") as img_file: img_file.write(image_data) @@ -40,7 +40,7 @@ def get_all_ipynb_files(examples_path="notebooks"): all_files = os.listdir(examples_path) return [ - (f"{path}/{examples_path}/{file}", file.split(".ipynb")[0]) + (os.path.join(path, examples_path, file), file.split(".ipynb")[0]) for file in all_files if file.endswith("ipynb") ] @@ -51,4 +51,4 @@ def get_all_ipynb_files(examples_path="notebooks"): files = get_all_ipynb_files() for file, folder in files: - convert_notebook_to_rst(file, f"{path}/source/examples/{folder}", folder) + convert_notebook_to_rst(file, os.path.join(path, source, examples,folder), folder)