coercer.core.MethodFilter

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3# File name          : MethodFilter.py
 4# Author             : Podalirius (@podalirius_)
 5# Date created       : 15 Sep 2022
 6
 7class MethodFilter(object):
 8    """
 9    Documentation for class MethodFilter
10    """
11
12    def __init__(self, filter_method_name=None, filter_protocol_name=None):
13        super(MethodFilter, self).__init__()
14        self.filter_method_name = filter_method_name
15        self.filter_protocol_name = filter_protocol_name
16
17    def matches_filter(self, instance):
18        """
19        Function matches_filter
20
21        Parameters:
22            ?:instance
23
24        Return:
25            bool:outcome
26        """
27        outcome = True
28        #
29        if self.filter_method_name is not None:
30            if self.filter_method_name in instance.function["name"]:
31                outcome = outcome and True
32            else:
33                outcome = outcome and False
34        #
35        if self.filter_protocol_name is not None:
36            if (self.filter_protocol_name in instance.protocol["shortname"]) or (self.filter_protocol_name in instance.protocol["longname"]):
37                outcome = outcome and True
38            else:
39                outcome = outcome and False
40        return outcome
41    
class MethodFilter:
 8class MethodFilter(object):
 9    """
10    Documentation for class MethodFilter
11    """
12
13    def __init__(self, filter_method_name=None, filter_protocol_name=None):
14        super(MethodFilter, self).__init__()
15        self.filter_method_name = filter_method_name
16        self.filter_protocol_name = filter_protocol_name
17
18    def matches_filter(self, instance):
19        """
20        Function matches_filter
21
22        Parameters:
23            ?:instance
24
25        Return:
26            bool:outcome
27        """
28        outcome = True
29        #
30        if self.filter_method_name is not None:
31            if self.filter_method_name in instance.function["name"]:
32                outcome = outcome and True
33            else:
34                outcome = outcome and False
35        #
36        if self.filter_protocol_name is not None:
37            if (self.filter_protocol_name in instance.protocol["shortname"]) or (self.filter_protocol_name in instance.protocol["longname"]):
38                outcome = outcome and True
39            else:
40                outcome = outcome and False
41        return outcome

Documentation for class MethodFilter

MethodFilter(filter_method_name=None, filter_protocol_name=None)
13    def __init__(self, filter_method_name=None, filter_protocol_name=None):
14        super(MethodFilter, self).__init__()
15        self.filter_method_name = filter_method_name
16        self.filter_protocol_name = filter_protocol_name
def matches_filter(self, instance):
18    def matches_filter(self, instance):
19        """
20        Function matches_filter
21
22        Parameters:
23            ?:instance
24
25        Return:
26            bool:outcome
27        """
28        outcome = True
29        #
30        if self.filter_method_name is not None:
31            if self.filter_method_name in instance.function["name"]:
32                outcome = outcome and True
33            else:
34                outcome = outcome and False
35        #
36        if self.filter_protocol_name is not None:
37            if (self.filter_protocol_name in instance.protocol["shortname"]) or (self.filter_protocol_name in instance.protocol["longname"]):
38                outcome = outcome and True
39            else:
40                outcome = outcome and False
41        return outcome

Function matches_filter

Parameters: ?:instance

Return: bool:outcome