-
Notifications
You must be signed in to change notification settings - Fork 74
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
Feature request: strip prefix from filenames #86
Comments
Good idea! Yappi is already showing the rightmost part of the string but I assume this is not enough for your case, right? One idea might be to strip off part of the string that contains a path in
becomes
because |
I probably should have mentioned: the context in which I found this difficult was feeding I think stripping |
I see. I agree that a bit of flexibility to filter some prefixes on the output would be useful. Will implement this in the next version! Again: Thanks for the idea! |
Yep, makes sense. Thanks for an awesome tool! |
I've got a rough patch for this fwiw YappiYFuncStat = yappi.YFuncStat
class YFuncStat(YappiYFuncStat):
def __setattr__(self, name, value):
if isinstance(value, str) and value.startswith("/"):
value = trim_sys_paths(value)
super().__setattr__(name, value)
yappi.YFuncStat = YFuncStat
def trim_sys_paths(path_string):
trim_length = 0
for path in sys.path:
if path_string.startswith(path) and len(path) > trim_length:
trim_length = len(path)
return path_string[trim_length:].lstrip("/") |
Thanks @madkinsz, I would happily merge this as a PR if you can:
|
I'd be happy to contribute, but the methods here for detecting a path and trimming values seems sloppy. I imagine you wouldn't want this implemented on |
I tried using
yappi
on some code that is executed through Bazel and it was difficult to read the stats because the paths all begin with an identical, deep prefix. Something like this:A
--prefix
or--strip-prefix
option that would allow me to drop the predictable and repeated parts of file paths would be a help to be able to focus on the more interesting part at the end.The text was updated successfully, but these errors were encountered: