Skip to content
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
50 changes: 28 additions & 22 deletions coercer/core/Filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,34 @@ def method_matches_filter(self, instance):
Return:
bool:outcome
"""
if len(self.filter_method_name) != 0 or len(self.filter_protocol_name) != 0:
outcome = False
else:
outcome = True
#
for method in self.filter_method_name:
if method in instance.function["name"]:
outcome = True
#
for protocol in self.filter_protocol_name:
if (protocol in instance.protocol["shortname"]) or (
protocol in instance.protocol["longname"]
):
outcome = True
#
"""
candidate_pipes = [p["namedpipe"] for p in instance.access["ncan_np"]]
for filter_pipe in self.filter_pipe_name:
if filter_pipe in candidate_pipes:
outcome = True
"""
return outcome
has_method_filters = len(self.filter_method_name) != 0
has_protocol_filters = len(self.filter_protocol_name) != 0

# No filters => accept everything
if not has_method_filters and not has_protocol_filters:
return True

# Compute individual matches
method_match = True if not has_method_filters else False
protocol_match = True if not has_protocol_filters else False
Comment on lines +39 to +40
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ternary operator here can be simplified for better readability. Instead of True if not has_method_filters else False, you can use not has_method_filters directly. The same applies to the protocol_match initialization.

Suggested change
method_match = True if not has_method_filters else False
protocol_match = True if not has_protocol_filters else False
method_match = not has_method_filters
protocol_match = not has_protocol_filters

Copilot uses AI. Check for mistakes.

if has_method_filters:
for method in self.filter_method_name:
if method in instance.function["name"]:
method_match = True
break

if has_protocol_filters:
for protocol in self.filter_protocol_name:
if (protocol in instance.protocol["shortname"]) or (
protocol in instance.protocol["longname"]
):
protocol_match = True
break

# When both filters are provided, require both to match (AND).
# When only one is provided, its match result is used.
return method_match and protocol_match

def pipe_matches_filter(self, pipe_name):
"""
Expand Down
Loading