Code Duplication    Length = 60-60 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 6201-6260 (lines=60) @@
6198
6199
        return self._send_xml_command(cmd)
6200
6201
    def modify_config_set_family_selection(
6202
        self,
6203
        config_id: str,
6204
        families: List[Tuple[str, bool, bool]],
6205
        *,
6206
        auto_add_new_families: Optional[bool] = True,
6207
    ) -> Any:
6208
        """
6209
        Selected the NVTs of a scan config at a family level.
6210
6211
        Arguments:
6212
            config_id: UUID of scan config to modify.
6213
            families: A list of tuples (str, bool, bool):
6214
                str: the name of the NVT family selected,
6215
                bool: add new NVTs  to the family automatically,
6216
                bool: include all NVTs from the family
6217
            auto_add_new_families: Whether new families should be added to the
6218
                scan config automatically. Default: True.
6219
        """
6220
        if not config_id:
6221
            raise RequiredArgument(
6222
                function=self.modify_config_set_family_selection.__name__,
6223
                argument='config_id',
6224
            )
6225
6226
        if not _is_list_like(families):
6227
            raise InvalidArgumentType(
6228
                function=self.modify_config_set_family_selection.__name__,
6229
                argument='families',
6230
                arg_type='list',
6231
            )
6232
6233
        cmd = XmlCommand("modify_config")
6234
        cmd.set_attribute("config_id", str(config_id))
6235
6236
        _xmlfamsel = cmd.add_element("family_selection")
6237
        _xmlfamsel.add_element("growing", _to_bool(auto_add_new_families))
6238
6239
        for family in families:
6240
            _xmlfamily = _xmlfamsel.add_element("family")
6241
            _xmlfamily.add_element("name", family[0])
6242
6243
            if len(family) != 3:
6244
                raise InvalidArgument(
6245
                    "Family must be a tuple of 3. (str, bool, bool)"
6246
                )
6247
6248
            if not isinstance(family[1], bool) or not isinstance(
6249
                family[2], bool
6250
            ):
6251
                raise InvalidArgumentType(
6252
                    function=self.modify_config_set_family_selection.__name__,
6253
                    argument='families',
6254
                    arg_type='[tuple(str, bool, bool)]',
6255
                )
6256
6257
            _xmlfamily.add_element("all", _to_bool(family[2]))
6258
            _xmlfamily.add_element("growing", _to_bool(family[1]))
6259
6260
        return self._send_xml_command(cmd)
6261
6262
    def modify_config(
6263
        self, config_id: str, selection: Optional[str] = None, **kwargs

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 4767-4826 (lines=60) @@
4764
4765
        return self._send_xml_command(cmd)
4766
4767
    def modify_config_set_family_selection(
4768
        self,
4769
        config_id: str,
4770
        families: List[Tuple[str, bool, bool]],
4771
        *,
4772
        auto_add_new_families: Optional[bool] = True,
4773
    ) -> Any:
4774
        """
4775
        Selected the NVTs of a scan config at a family level.
4776
4777
        Arguments:
4778
            config_id: UUID of scan config to modify.
4779
            families: A list of tuples (str, bool, bool):
4780
                str: the name of the NVT family selected,
4781
                bool: add new NVTs  to the family automatically,
4782
                bool: include all NVTs from the family
4783
            auto_add_new_families: Whether new families should be added to the
4784
                scan config automatically. Default: True.
4785
        """
4786
        if not config_id:
4787
            raise RequiredArgument(
4788
                function=self.modify_config_set_family_selection.__name__,
4789
                argument='config_id',
4790
            )
4791
4792
        if not _is_list_like(families):
4793
            raise InvalidArgumentType(
4794
                function=self.modify_config_set_family_selection.__name__,
4795
                argument='families',
4796
                arg_type='list',
4797
            )
4798
4799
        cmd = XmlCommand("modify_config")
4800
        cmd.set_attribute("config_id", str(config_id))
4801
4802
        _xmlfamsel = cmd.add_element("family_selection")
4803
        _xmlfamsel.add_element("growing", _to_bool(auto_add_new_families))
4804
4805
        for family in families:
4806
            _xmlfamily = _xmlfamsel.add_element("family")
4807
            _xmlfamily.add_element("name", family[0])
4808
4809
            if len(family) != 3:
4810
                raise InvalidArgument(
4811
                    "Family must be a tuple of 3. (str, bool, bool)"
4812
                )
4813
4814
            if not isinstance(family[1], bool) or not isinstance(
4815
                family[2], bool
4816
            ):
4817
                raise InvalidArgumentType(
4818
                    function=self.modify_config_set_family_selection.__name__,
4819
                    argument='families',
4820
                    arg_type='[tuple(str, bool, bool)]',
4821
                )
4822
4823
            _xmlfamily.add_element("all", _to_bool(family[2]))
4824
            _xmlfamily.add_element("growing", _to_bool(family[1]))
4825
4826
        return self._send_xml_command(cmd)
4827
4828
    def modify_config(
4829
        self, config_id: str, selection: Optional[str] = None, **kwargs