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

[Backport master] Merge the filters #2538

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions c2cwsgiutils/debug/_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ def _show_refs(request: pyramid.request.Request) -> pyramid.response.Response:
args["extra_info"] = lambda obj: f"{get_size(obj) / 1024:.3f} kb\n{id(obj)}"

result = StringIO()
if request.params.get("backrefs", "") != "":
objgraph.show_backrefs(objs, output=result, **args)
else:
objgraph.show_refs(objs, output=result, filter=lambda x: not objgraph.inspect.isclass(x), **args)
if request.params.get("backrefs", "") == "":

def new_filter(x: Any) -> bool:
return not objgraph.inspect.isclass(x)

if "filter" in args:
old_filter = args["filter"]
args["filter"] = lambda x: old_filter(x) and new_filter(x)
else:
args["filter"] = new_filter
objgraph.show_backrefs(objs, output=result, **args)

request.response.content_type = "text/vnd.graphviz"
request.response.text = result.getvalue()
Expand Down
Loading