From 232e8184129a036f66f24dabd944159edbbb1e70 Mon Sep 17 00:00:00 2001 From: Cody Scott Date: Sat, 3 Feb 2024 18:03:27 -0500 Subject: [PATCH] Refactor get_project_dir() --- htmd/site.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/htmd/site.py b/htmd/site.py index 900bd45..e3d61ad 100644 --- a/htmd/site.py +++ b/htmd/site.py @@ -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()