@@ -17,8 +17,8 @@ class QuartoReportView(r.ReportView):
1717 A ReportView subclass for generating Quarto reports.
1818 """
1919
20- BASE_DIR = "quarto_report"
21- STATIC_FILES_DIR = Path ( BASE_DIR ) / "static"
20+ BASE_DIR = Path ( "quarto_report" )
21+ STATIC_FILES_DIR = BASE_DIR / "static"
2222
2323 def __init__ (self , report : r .Report , report_type : r .ReportType ):
2424 super ().__init__ (report = report , report_type = report_type )
@@ -33,16 +33,16 @@ def __init__(self, report: r.Report, report_type: r.ReportType):
3333 self .report .logger .info ("running in a normal Python process" )
3434
3535 def generate_report (
36- self , output_dir : str = BASE_DIR , static_dir : str = STATIC_FILES_DIR
36+ self , output_dir : Path = BASE_DIR , static_dir : Path = STATIC_FILES_DIR
3737 ) -> None :
3838 """
3939 Generates the qmd file of the quarto report. It creates code for rendering each section and its subsections with all components.
4040
4141 Parameters
4242 ----------
43- output_dir : str , optional
43+ output_dir : Path , optional
4444 The folder where the generated report files will be saved (default is BASE_DIR).
45- static_dir : str , optional
45+ static_dir : Path , optional
4646 The folder where the static files will be saved (default is STATIC_FILES_DIR).
4747 """
4848 self .report .logger .debug (
@@ -165,7 +165,7 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
165165 """
166166 # from quarto_cli import run_quarto # entrypoint of quarto-cli not in module?
167167
168- file_path_to_qmd = os . path . join ( output_dir , f"{ self .BASE_DIR } .qmd" )
168+ file_path_to_qmd = str ( Path ( output_dir ) / f"{ self .BASE_DIR } .qmd"
169169 args = [self .quarto_path , "render" , file_path_to_qmd ]
170170 self .report .logger .info (
171171 f"Running '{ self .report .title } ' '{ self .report_type } ' report with { args !r} "
@@ -185,11 +185,7 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
185185 )
186186 try :
187187 subprocess .run (
188- [
189- self .quarto_path ,
190- "render" ,
191- os .path .join (output_dir , f"{ self .BASE_DIR } .qmd" ),
192- ],
188+ args ,
193189 check = True ,
194190 )
195191 if self .report_type == r .ReportType .JUPYTER :
@@ -460,7 +456,7 @@ def _generate_plot_content(
460456 plot_content .append (self ._generate_plot_code (plot ))
461457 if is_report_static :
462458 plot_content .append (
463- f"""fig_plotly.write_image("{ static_plot_path .resolve ()} ")\n ```\n """
459+ f"""fig_plotly.write_image("{ static_plot_path .resolve (). as_posix () } ")\n ```\n """
464460 )
465461 plot_content .append (self ._generate_image_content (static_plot_path ))
466462 else :
@@ -469,7 +465,7 @@ def _generate_plot_content(
469465 plot_content .append (self ._generate_plot_code (plot ))
470466 if is_report_static :
471467 plot_content .append (
472- f"""fig_altair.save("{ static_plot_path .resolve ()} ")\n ```\n """
468+ f"""fig_altair.save("{ static_plot_path .resolve (). as_posix () } ")\n ```\n """
473469 )
474470 plot_content .append (self ._generate_image_content (static_plot_path ))
475471 else :
@@ -542,7 +538,7 @@ def _generate_plot_code(self, plot, output_file="") -> str:
542538plot_json = response.text\n """
543539 else : # If it's a local file
544540 plot_code += f"""
545- with open('{ Path (".." ) / plot .file_path } ', 'r') as plot_file:
541+ with open('{ ( Path (".." ) / plot .file_path ). as_posix () } ', 'r') as plot_file:
546542 plot_json = plot_file.read()\n """
547543 # Add specific code for each visualization tool
548544 if plot .plot_type == r .PlotType .PLOTLY :
@@ -620,7 +616,7 @@ def _generate_dataframe_content(self, dataframe, is_report_static) -> List[str]:
620616 # Load the DataFrame using the correct function
621617 read_function = read_function_mapping [file_extension ]
622618 dataframe_content .append (
623- f"""df = pd.{ read_function .__name__ } ('{ file_path } ')"""
619+ f"""df = pd.{ read_function .__name__ } ('{ file_path . as_posix () } ')\n """
624620 )
625621
626622 # Display the dataframe
@@ -677,7 +673,7 @@ def _generate_markdown_content(self, markdown) -> List[str]:
677673 else : # If it's a local file
678674 markdown_content .append (
679675 f"""
680- with open('{ Path (".." ) / markdown .file_path } ', 'r') as markdown_file:
676+ with open('{ ( Path (".." ) / markdown .file_path ). as_posix () } ', 'r') as markdown_file:
681677 markdown_content = markdown_file.read()\n """
682678 )
683679
@@ -800,7 +796,7 @@ def _show_dataframe(
800796 # Generate path for the DataFrame image
801797 df_image = Path (static_dir ) / f"{ dataframe .title .replace (' ' , '_' )} .png"
802798 dataframe_content .append (
803- f"df.dfi.export('{ Path (df_image ).resolve ()} ', max_rows=10, max_cols=5)\n ```\n "
799+ f"df.dfi.export('{ Path (df_image ).resolve (). as_posix () } ', max_rows=10, max_cols=5)\n ```\n "
804800 )
805801 # Use helper method to add centered image content
806802 dataframe_content .append (self ._generate_image_content (df_image ))
0 commit comments