Skip to content

Commit

Permalink
Merge the filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 20, 2024
1 parent 435cf7c commit 6ffe50a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions c2cwsgiutils/debug/_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,14 @@ 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", "") == "":
new_filter = lambda x: 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

0 comments on commit 6ffe50a

Please sign in to comment.