Code Duplication    Length = 13-13 lines in 3 locations

gvm/protocols/gmpv208/entities/tasks.py 2 locations

@@ 323-335 (lines=13) @@
320
321
            cmd.add_element("observers", to_comma_list(observers))
322
323
        if preferences is not None:
324
            if not isinstance(preferences, Mapping):
325
                raise InvalidArgumentType(
326
                    function=self.modify_task.__name__,
327
                    argument='preferences',
328
                    arg_type=Mapping.__name__,
329
                )
330
331
            _xmlprefs = cmd.add_element("preferences")
332
            for pref_name, pref_value in preferences.items():
333
                _xmlpref = _xmlprefs.add_element("preference")
334
                _xmlpref.add_element("scanner_name", pref_name)
335
                _xmlpref.add_element("value", str(pref_value))
336
337
        return self._send_xml_command(cmd)
338
@@ 176-188 (lines=13) @@
173
            # user id. So both user name and user id are possible
174
            cmd.add_element("observers", to_comma_list(observers))
175
176
        if preferences is not None:
177
            if not isinstance(preferences, Mapping):
178
                raise InvalidArgumentType(
179
                    function=self.create_task.__name__,
180
                    argument='preferences',
181
                    arg_type=Mapping.__name__,
182
                )
183
184
            _xmlprefs = cmd.add_element("preferences")
185
            for pref_name, pref_value in preferences.items():
186
                _xmlpref = _xmlprefs.add_element("preference")
187
                _xmlpref.add_element("scanner_name", pref_name)
188
                _xmlpref.add_element("value", str(pref_value))
189
190
        return self._send_xml_command(cmd)
191

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 1499-1511 (lines=13) @@
1496
            # user id. So both user name and user id are possible
1497
            cmd.add_element("observers", to_comma_list(observers))
1498
1499
        if preferences is not None:
1500
            if not isinstance(preferences, collections.abc.Mapping):
1501
                raise InvalidArgumentType(
1502
                    function=function,
1503
                    argument='preferences',
1504
                    arg_type=collections.abc.Mapping.__name__,
1505
                )
1506
1507
            _xmlprefs = cmd.add_element("preferences")
1508
            for pref_name, pref_value in preferences.items():
1509
                _xmlpref = _xmlprefs.add_element("preference")
1510
                _xmlpref.add_element("scanner_name", pref_name)
1511
                _xmlpref.add_element("value", str(pref_value))
1512
1513
        return self._send_xml_command(cmd)
1514