Skip to content

Commit f9c0544

Browse files
committed
🐛 Fix(config_manager.py and quarto_reportview.py):Remove _resolve_base_dir function in config_manager.py and use absolute paths i to export images in quarto_reportview.py
1 parent 2d89b6d commit f9c0544

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

vuegen/config_manager.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -211,32 +211,6 @@ def _create_sect_config_fromdir(self, section_dir_path: Path) -> Dict[str, Union
211211

212212
return section_config
213213

214-
def _resolve_base_dir(self, base_dir: str) -> Path:
215-
"""
216-
Resolves the provided base directory to an absolute path from the root, accounting for relative paths.
217-
218-
Parameters
219-
----------
220-
base_dir : str
221-
The relative or absolute path to the base directory.
222-
223-
Returns
224-
-------
225-
Path
226-
The absolute path to the base directory.
227-
"""
228-
# Check if we are in a subdirectory and need to go up one level
229-
project_dir = Path(__file__).resolve().parents[1]
230-
231-
# If the base_dir is a relative path, resolve it from the project root
232-
base_dir_path = project_dir / base_dir
233-
234-
# Make sure the resolved base directory exists
235-
if not base_dir_path.is_dir():
236-
raise ValueError(f"Base directory '{base_dir}' does not exist or is not a directory. {project_dir} {base_dir_path}")
237-
238-
return base_dir_path
239-
240214
def create_yamlconfig_fromdir(self, base_dir: str) -> Tuple[Dict[str, Union[str, List[Dict]]], Path]:
241215
"""
242216
Generates a YAML-compatible config file from a directory. It also returns the resolved folder path.
@@ -252,7 +226,7 @@ def create_yamlconfig_fromdir(self, base_dir: str) -> Tuple[Dict[str, Union[str,
252226
The YAML config and the resolved directory path.
253227
"""
254228
# Get absolute path from base directory
255-
base_dir_path = self._resolve_base_dir(base_dir)
229+
base_dir_path = Path(base_dir)
256230

257231
# Generate the YAML config
258232
yaml_config = {

vuegen/quarto_reportview.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ def _generate_plot_content(self, plot, is_report_static, static_dir: str = STATI
283283
elif plot.plot_type == r.PlotType.PLOTLY:
284284
plot_content.append(self._generate_plot_code(plot))
285285
if is_report_static:
286-
plot_content.append(f"""fig_plotly.write_image("{os.path.join("..", static_plot_path)}")\n```\n""")
286+
plot_content.append(f"""fig_plotly.write_image("{os.path.abspath(static_plot_path)}")\n```\n""")
287287
plot_content.append(self._generate_image_content(static_plot_path))
288288
else:
289289
plot_content.append(f"""fig_plotly.show()\n```\n""")
290290
elif plot.plot_type == r.PlotType.ALTAIR:
291291
plot_content.append(self._generate_plot_code(plot))
292292
if is_report_static:
293-
plot_content.append(f"""fig_altair.save("{os.path.join("..", static_plot_path)}")\n```\n""")
293+
plot_content.append(f"""fig_altair.save("{os.path.abspath(static_plot_path)}")\n```\n""")
294294
plot_content.append(self._generate_image_content(static_plot_path))
295295
else:
296296
plot_content.append(f"""fig_altair\n```\n""")
@@ -537,7 +537,7 @@ def _show_dataframe(self, dataframe, is_report_static, static_dir: str = STATIC_
537537
if is_report_static:
538538
# Generate path for the DataFrame image
539539
df_image = os.path.join(static_dir, f"{dataframe.title.replace(' ', '_')}.png")
540-
dataframe_content.append(f"dfi.export(df, '{os.path.join('..', df_image)}', max_rows=10, max_cols=5)\n```\n")
540+
dataframe_content.append(f"dfi.export(df, '{os.path.abspath(df_image)}', max_rows=10, max_cols=5)\n```\n")
541541
# Use helper method to add centered image content
542542
dataframe_content.append(self._generate_image_content(df_image))
543543
else:

0 commit comments

Comments
 (0)