Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into more_fixes
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/test_pyfileindex.py
  • Loading branch information
jan-janssen committed May 14, 2023
2 parents b3c46d8 + b5aea98 commit 84b004c
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions pyfileindex/pyfileindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,25 @@ def open(self, path):
PyFileIndex: PyFileIndex for subdirectory
"""
abs_path = os.path.abspath(os.path.expanduser(os.path.join(self._path, path)))
if abs_path == self._path:
return self
elif os.path.commonpath([abs_path, self._path]) == self._path:
return PyFileIndex(
path=abs_path,
filter_function=self._filter_function,
debug=self._debug,
df=self._df[self._df["path"].str.contains(abs_path)],
)
if os.path.exists(abs_path):
if abs_path == self._path:
return self
elif os.path.commonpath([abs_path, self._path]) == self._path:
return PyFileIndex(
path=abs_path,
filter_function=self._filter_function,
debug=self._debug,
df=self._df[self._df["path"].str.contains(abs_path)],
)
else:
return PyFileIndex(
path=abs_path,
filter_function=self._filter_function,
debug=self._debug,
)
else:
return PyFileIndex(
path=abs_path, filter_function=self._filter_function, debug=self._debug
raise FileNotFoundError(
"The path " + abs_path + " does not exist on your filesystem."
)

def update(self):
Expand Down

0 comments on commit 84b004c

Please sign in to comment.