Repository navigation
gh-161299: Resolve Gecko profiler resources to module names - #161310
makwana-akshat wants to merge 2 commits into
Conversation
| resource_name = ( | ||
| os.path.basename(filename) if "/" in filename else filename | ||
| norm_filename = ( | ||
| filename.replace("\\", "/") if "\\" in filename else filename |
There was a problem hiding this comment.
Why not just using os.path.sep for the separator in filenames? You don't need to have the if either. And it's not really a norm_filename as normalized filenames are not that.
| resource_idx = len(resource_names) | ||
| resource_name = ( | ||
| os.path.basename(filename) if "/" in filename else filename | ||
| norm_filename = ( |
There was a problem hiding this comment.
I think a lot of this logic can be simplified using pathlib.Path.
There was a problem hiding this comment.
Thanks for both suggestions!
I've simplified the fallback path handling using pathlib, replacing the manual string-splitting logic with Path.name and Path.parent.name. I've also removed the misleading norm_filename variable and the unnecessary conditional around separator replacement.
I retained PureWindowsPath to handle Windows-style paths correctly on POSIX systems. Backslashes are replaced with forward slashes before calling extract_module_name() to ensure module names are resolved consistently across platforms.
Summary
Tests
module_utilstests: 4 passed using the local test runner.git diff --check: passed.Issue
Related to #161299.