-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed tests with new file_path function & unit test
- Loading branch information
Showing
4 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .general_utils import find_file_path | ||
from .makellm import _make_llm | ||
from .path_registry import FileType, PathRegistry | ||
|
||
__all__ = ["_make_llm", "PathRegistry", "FileType"] | ||
__all__ = ["_make_llm", "PathRegistry", "FileType", "find_file_path"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
|
||
|
||
def find_file_path(file_name: str, exact_match: bool = True): | ||
"""get the path of a file, if it exists in repo""" | ||
setup_dir = None | ||
for dirpath, dirnames, filenames in os.walk("."): | ||
if "setup.py" in filenames: | ||
setup_dir = dirpath | ||
break | ||
|
||
if setup_dir is None: | ||
raise FileNotFoundError("Unable to find root directory.") | ||
|
||
for dirpath, dirnames, filenames in os.walk(setup_dir): | ||
for filename in filenames: | ||
if (exact_match and filename == file_name) or ( | ||
not exact_match and file_name in filename | ||
): | ||
return os.path.join(dirpath, filename) | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters