Code Duplication    Length = 44-44 lines in 2 locations

gvm/protocols/gmpv8/gmpv8.py 1 location

@@ 883-926 (lines=44) @@
880
881
        return self._send_xml_command(cmd)
882
883
    def create_filter(
884
        self,
885
        name: str,
886
        *,
887
        filter_type: Optional[FilterType] = None,
888
        comment: Optional[str] = None,
889
        term: Optional[str] = None,
890
    ) -> Any:
891
        """Create a new filter
892
893
        Arguments:
894
            name: Name of the new filter
895
            filter_type: Filter for entity type
896
            comment: Comment for the filter
897
            term: Filter term e.g. 'name=foo'
898
899
        Returns:
900
            The response. See :py:meth:`send_command` for details.
901
        """
902
        if not name:
903
            raise RequiredArgument(
904
                function=self.create_filter.__name__, argument="name"
905
            )
906
907
        cmd = XmlCommand("create_filter")
908
        _xmlname = cmd.add_element("name", name)
909
910
        if comment:
911
            cmd.add_element("comment", comment)
912
913
        if term:
914
            cmd.add_element("term", term)
915
916
        if filter_type:
917
            if not isinstance(filter_type, self.types.FilterType):
918
                raise InvalidArgumentType(
919
                    function=self.create_filter.__name__,
920
                    argument="filter_type",
921
                    arg_type=self.types.FilterType.__name__,
922
                )
923
924
            cmd.add_element("type", filter_type.value)
925
926
        return self._send_xml_command(cmd)
927
928
    def modify_filter(
929
        self,

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 3084-3127 (lines=44) @@
3081
3082
        return self._send_xml_command(cmd)
3083
3084
    def create_filter(
3085
        self,
3086
        name: str,
3087
        *,
3088
        filter_type: Optional[FilterType] = None,
3089
        comment: Optional[str] = None,
3090
        term: Optional[str] = None,
3091
    ) -> Any:
3092
        """Create a new filter
3093
3094
        Arguments:
3095
            name: Name of the new filter
3096
            filter_type: Filter for entity type
3097
            comment: Comment for the filter
3098
            term: Filter term e.g. 'name=foo'
3099
3100
        Returns:
3101
            The response. See :py:meth:`send_command` for details.
3102
        """
3103
        if not name:
3104
            raise RequiredArgument(
3105
                function=self.create_filter.__name__, argument="name"
3106
            )
3107
3108
        cmd = XmlCommand("create_filter")
3109
        _xmlname = cmd.add_element("name", name)
3110
3111
        if comment:
3112
            cmd.add_element("comment", comment)
3113
3114
        if term:
3115
            cmd.add_element("term", term)
3116
3117
        if filter_type:
3118
            if not isinstance(filter_type, self.types.FilterType):
3119
                raise InvalidArgumentType(
3120
                    function=self.create_filter.__name__,
3121
                    argument="filter_type",
3122
                    arg_type=self.types.FilterType.__name__,
3123
                )
3124
3125
            cmd.add_element("type", filter_type.value)
3126
3127
        return self._send_xml_command(cmd)
3128
3129
    def modify_filter(
3130
        self,