OpenPecha / Toolkit

🛠 Tools to create, edit and export texts and annotations
https://toolkit.openpecha.org
Apache License 2.0
7 stars 4 forks source link

bug with get_opf_path method in OpenPechaGitRepo class #267

Closed gangagyatso4364 closed 8 months ago

gangagyatso4364 commented 8 months ago

Describe the bug The function get_opf_path is designed to convert a pecha path to the corresponding OpenPecha Format (OPF) path. However, there is a bug in the function's implementation. Specifically, when the path parameter is not provided (None), the function is expected to download the pecha using the download_pecha function and then return the path to the downloaded OPF. But currently, the function returns immediately after calling download_pecha(pecha_id), without converting the downloaded pecha's path to the OPF path.

This premature return occurs at line 446 with return download_pecha(pecha_id). This line should instead set the path variable to the result of download_pecha(pecha_id) and then continue with the subsequent steps to convert this path to the OPF path.

In essence, the bug is that the function exits too early when the path argument is not provided, and it does not fulfill its intended purpose of always returning the OPF path.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior The get_opf_path function in Python, given a pecha_id and an optional path, either downloads the pecha (if the path is not provided) or uses the given path, then it transforms this path into an OpenPecha Format (OPF) path and verifies its existence before returning it. This function is designed to ensure that the returned path correctly points to the OPF directory of the specified pecha.

Screenshots Screenshot from 2024-01-08 16-51-14

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

github-actions[bot] commented 8 months ago

Welcome! 😁 This is your first Issue