Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor get_project_dir() #28

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions htmd/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,15 @@
def get_project_dir() -> Path:
current_directory = Path.cwd()

while True:
file_path = current_directory / 'config.toml'

if file_path.is_file():
return current_directory

# Move to the parent directory
while not (current_directory / 'config.toml').is_file():
parent_directory = current_directory.parent

# If the current and parent directories are the same, break the loop
if current_directory == parent_directory:
break
return Path.cwd()

current_directory = parent_directory

return Path.cwd()
return current_directory


project_dir = get_project_dir()
Expand Down
10 changes: 8 additions & 2 deletions tests/test_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ def test_preview_reload_css(run_start: CliRunner) -> None: # noqa: ARG001
while after == before:
try:
response = requests.get(url, timeout=0.1)
except requests.exceptions.ReadTimeout:
except (
requests.exceptions.ReadTimeout,
requests.exceptions.ConnectionError,
):
# happens during restart
read_timeout = True
else:
Expand Down Expand Up @@ -182,7 +185,10 @@ def test_preview_reload_js(run_start: CliRunner) -> None: # noqa: ARG001
while after == before:
try:
response = requests.get(url, timeout=0.1)
except requests.exceptions.ReadTimeout:
except (
requests.exceptions.ReadTimeout,
requests.exceptions.ConnectionError,
):
# happens during restart
read_timeout = True
else:
Expand Down
Loading