@@ -15,23 +15,23 @@ class QuartoReportView(r.ReportView):
1515 A ReportView subclass for generating Quarto reports.
1616 """
1717
18- BASE_DIR = "quarto_report"
19- STATIC_FILES_DIR = Path ( BASE_DIR ) / "static"
18+ BASE_DIR = Path ( "quarto_report" )
19+ STATIC_FILES_DIR = BASE_DIR / "static"
2020
2121 def __init__ (self , report : r .Report , report_type : r .ReportType ):
2222 super ().__init__ (report = report , report_type = report_type )
2323
2424 def generate_report (
25- self , output_dir : str = BASE_DIR , static_dir : str = STATIC_FILES_DIR
25+ self , output_dir : Path = BASE_DIR , static_dir : Path = STATIC_FILES_DIR
2626 ) -> None :
2727 """
2828 Generates the qmd file of the quarto report. It creates code for rendering each section and its subsections with all components.
2929
3030 Parameters
3131 ----------
32- output_dir : str , optional
32+ output_dir : Path , optional
3333 The folder where the generated report files will be saved (default is BASE_DIR).
34- static_dir : str , optional
34+ static_dir : Path , optional
3535 The folder where the static files will be saved (default is STATIC_FILES_DIR).
3636 """
3737 self .report .logger .debug (
@@ -154,15 +154,15 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
154154 """
155155 try :
156156 subprocess .run (
157- ["quarto" , "render" , Path (output_dir ) / f"{ self .BASE_DIR } .qmd" ],
157+ ["quarto" , "render" , str ( Path (output_dir ) / f"{ self .BASE_DIR } .qmd" ) ],
158158 check = True ,
159159 )
160160 if self .report_type == r .ReportType .JUPYTER :
161161 subprocess .run (
162162 [
163163 "quarto" ,
164164 "convert" ,
165- Path (output_dir ) / f"{ self .BASE_DIR } .qmd" ,
165+ str ( Path (output_dir ) / f"{ self .BASE_DIR } .qmd" ) ,
166166 ],
167167 check = True ,
168168 )
@@ -425,7 +425,7 @@ def _generate_plot_content(
425425 plot_content .append (self ._generate_plot_code (plot ))
426426 if is_report_static :
427427 plot_content .append (
428- f"""fig_plotly.write_image("{ static_plot_path .resolve ()} ")\n ```\n """
428+ f"""fig_plotly.write_image("{ static_plot_path .resolve (). as_posix () } ")\n ```\n """
429429 )
430430 plot_content .append (self ._generate_image_content (static_plot_path ))
431431 else :
@@ -434,7 +434,7 @@ def _generate_plot_content(
434434 plot_content .append (self ._generate_plot_code (plot ))
435435 if is_report_static :
436436 plot_content .append (
437- f"""fig_altair.save("{ static_plot_path .resolve ()} ")\n ```\n """
437+ f"""fig_altair.save("{ static_plot_path .resolve (). as_posix () } ")\n ```\n """
438438 )
439439 plot_content .append (self ._generate_image_content (static_plot_path ))
440440 else :
@@ -507,7 +507,7 @@ def _generate_plot_code(self, plot, output_file="") -> str:
507507plot_json = response.text\n """
508508 else : # If it's a local file
509509 plot_code += f"""
510- with open('{ Path (".." ) / plot .file_path } ', 'r') as plot_file:
510+ with open('{ ( Path (".." ) / plot .file_path ). as_posix () } ', 'r') as plot_file:
511511 plot_json = plot_file.read()\n """
512512 # Add specific code for each visualization tool
513513 if plot .plot_type == r .PlotType .PLOTLY :
@@ -585,7 +585,7 @@ def _generate_dataframe_content(self, dataframe, is_report_static) -> List[str]:
585585 # Load the DataFrame using the correct function
586586 read_function = read_function_mapping [file_extension ]
587587 dataframe_content .append (
588- f"""df = pd.{ read_function .__name__ } ('{ file_path } ')"""
588+ f"""df = pd.{ read_function .__name__ } ('{ file_path . as_posix () } ')\n """
589589 )
590590
591591 # Display the dataframe
@@ -642,7 +642,7 @@ def _generate_markdown_content(self, markdown) -> List[str]:
642642 else : # If it's a local file
643643 markdown_content .append (
644644 f"""
645- with open('{ Path (".." ) / markdown .file_path } ', 'r') as markdown_file:
645+ with open('{ ( Path (".." ) / markdown .file_path ). as_posix () } ', 'r') as markdown_file:
646646 markdown_content = markdown_file.read()\n """
647647 )
648648
@@ -765,7 +765,7 @@ def _show_dataframe(
765765 # Generate path for the DataFrame image
766766 df_image = Path (static_dir ) / f"{ dataframe .title .replace (' ' , '_' )} .png"
767767 dataframe_content .append (
768- f"df.dfi.export('{ Path (df_image ).resolve ()} ', max_rows=10, max_cols=5)\n ```\n "
768+ f"df.dfi.export('{ Path (df_image ).resolve (). as_posix () } ', max_rows=10, max_cols=5)\n ```\n "
769769 )
770770 # Use helper method to add centered image content
771771 dataframe_content .append (self ._generate_image_content (df_image ))
0 commit comments