-
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 2 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,18 @@ 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 | ||||||||||||||||||||||||||||||||||||||||
return absolute.normalize() | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
def normalize(self: P) -> P: | ||||||||||||||||||||||||||||||||||||||||
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. A quick initial impression while I have a closer look at this: we should not be introducing new public methods like this, they're not part of the 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. good point. this method is a good private 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 disagree but we're already doing this: see 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. done |
||||||||||||||||||||||||||||||||||||||||
for index, part in enumerate(self._path_parts): | ||||||||||||||||||||||||||||||||||||||||
# we can't normalize '/../stuff' so let's ignore such scenarios | ||||||||||||||||||||||||||||||||||||||||
if index == 0 or part != "..": | ||||||||||||||||||||||||||||||||||||||||
continue | ||||||||||||||||||||||||||||||||||||||||
segments = list(self._path_parts) | ||||||||||||||||||||||||||||||||||||||||
segments.pop(index) | ||||||||||||||||||||||||||||||||||||||||
segments.pop(index - 1) | ||||||||||||||||||||||||||||||||||||||||
return self.with_segments(self.anchor, *segments).normalize() | ||||||||||||||||||||||||||||||||||||||||
return self | ||||||||||||||||||||||||||||||||||||||||
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.
Suggested change
can we perhaps get a non-recursive option? 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. done |
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
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