-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resource path resolver #20
base: extract-handlers
Are you sure you want to change the base?
Conversation
type=self.get_type(), | ||
events=self.get_preservation_events(), | ||
metadata_files=self.get_metadata_files(), | ||
data_files=self.get_data_files(), | ||
struct_maps=self.get_struct_maps(), | ||
) | ||
|
||
def _apply_relative_path(self, descriptor_path: Path, path_to_apply: str) -> str: | ||
if path_to_apply.startswith("../"): |
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.
I need to think some more about this; we don't want a path relative to the running directory (cwd
) --- that's too much path. Working in the console doing the following gives the result I was expecting.
combined_path = (descriptor_path / path_to_apply)
new_relative_path = combined_path.relative_to(descriptor_path / "..")
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.
Yes, you are correct.I tried a different approach, but when I run the tests from the CWD, it causes the paths to be resolved from there. This creates issue because I need the paths to be relative to a specific directory, not the CWD.
I moved the _apply_relative_path method to the Parser class instead of PackageResourceProvider to avoid a circular dependency. Additionally, since the resolution of the path for locref is now happening within the parser, I added the _apply_relative_path method there.
Please let me know if you think this approach is sound or if you have any alternative suggestions.