-
Notifications
You must be signed in to change notification settings - Fork 10
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
normalize databricks paths as part of resolving them #157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,7 +520,23 @@ def resolve(self: P, strict: bool = False) -> P: | |
if strict and not absolute.exists(): | ||
msg = f"Path does not exist: {self}" | ||
raise FileNotFoundError(msg) | ||
return absolute | ||
# pylint: disable=protected-access | ||
return absolute._normalize() | ||
|
||
def _normalize(self: P) -> P: | ||
if ".." not in self._path_parts: | ||
return self | ||
segments: list[str] = [] | ||
for part in self._path_parts: | ||
if part == "..": | ||
if segments: | ||
segments.pop() | ||
elif part is None or part == '.': | ||
continue | ||
Comment on lines
+534
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed: by the time we get here a part can neither be |
||
else: | ||
segments.append(part) | ||
# pylint: disable=protected-access | ||
return self.with_segments(self.anchor, *segments)._normalize() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit unclear to me why we need to also call |
||
|
||
def absolute(self: P) -> P: | ||
if self.is_absolute(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't
self.absolute()
fail becauseself.cwd()
is not available for_DatabricksPath
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will but that's not the problem being addressed by this PR