Skip to content

Commit

Permalink
remove dir only logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfulton9 committed Sep 16, 2024
1 parent 1f8b40e commit 41555a1
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/jupyter-ai/jupyter_ai/document_loaders/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,9 @@ def collect_filepaths(path, all_files: bool):
filepaths = walk_directory(path, all_files)
else:
filepaths = []
directories = []
for glob_path in iglob(str(path), include_hidden=all_files, recursive=True):
if os.path.isfile(glob_path):
filepaths.append(Path(glob_path))
continue
# only keep directories if no files
elif len(filepaths) == 0:
directories.append(glob_path)
# walk the directories if only directories are returned from iglob
if not filepaths and directories:
filepaths = list(
{
Path(path)
for dir_paths in map(
lambda p: walk_directory(p, all_files), directories
)
for path in dir_paths
}
)
valid_exts = {j.lower() for j in SUPPORTED_EXTS}
filepaths = [fp for fp in filepaths if fp.suffix.lower() in valid_exts]
return filepaths
Expand Down

0 comments on commit 41555a1

Please sign in to comment.