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

@@ 1318-1330 (lines=13) @@
1315
            # user id. So both user name and user id are possible
1316
            cmd.add_element("observers", to_comma_list(observers))
1317
1318
        if preferences is not None:
1319
            if not isinstance(preferences, collections.abc.Mapping):
1320
                raise InvalidArgumentType(
1321
                    function=function,
1322
                    argument='preferences',
1323
                    arg_type=collections.abc.Mapping.__name__,
1324
                )
1325
1326
            _xmlprefs = cmd.add_element("preferences")
1327
            for pref_name, pref_value in preferences.items():
1328
                _xmlpref = _xmlprefs.add_element("preference")
1329
                _xmlpref.add_element("scanner_name", pref_name)
1330
                _xmlpref.add_element("value", str(pref_value))
1331
1332
        return self._send_xml_command(cmd)
1333