PyBites-Open-Source / eatlocal

This package helps users solve PyBites code challenges on their local machine.
MIT License
20 stars 9 forks source link

Only run code for display if bite is downloaded #23

Closed pmayd closed 2 years ago

pmayd commented 2 years ago

When you try to run eatlocal display <bite-no> without having downloaded the bite first, you will get a very long error message resulting in an IndexError because there is no html file in the local repo: html_file = path / list(path.glob("*.html"))[0]. This is expected but the user should be informed that they can only display bites that were downloaded before. So we should check first, if there is a path for that bite number.

Should be a very easy fix.

Given the line:

path = Path(bite_path or Path.cwd()).resolve() / str(bite_number)

it should suffice to check if that path is an existing directory and if not, display a warning message on the console.

rhelmstedter commented 2 years ago

That is a great idea. And you were right. Super easy fix.

Just addressed this with commit: 345a72767c338501abe11aea70c6940317f61c05