Skip to content
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

Open
wants to merge 5 commits into
base: extract-handlers
Choose a base branch
from

Conversation

jayamala17
Copy link
Contributor

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.

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("../"):
Copy link
Collaborator

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 / "..")

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants