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

@@ 1830-1842 (lines=13) @@
1827
            # user id. So both user name and user id are possible
1828
            cmd.add_element("observers", to_comma_list(observers))
1829
1830
        if preferences is not None:
1831
            if not isinstance(preferences, collections.abc.Mapping):
1832
                raise InvalidArgumentType(
1833
                    function=function,
1834
                    argument='preferences',
1835
                    arg_type=collections.abc.Mapping.__name__,
1836
                )
1837
1838
            _xmlprefs = cmd.add_element("preferences")
1839
            for pref_name, pref_value in preferences.items():
1840
                _xmlpref = _xmlprefs.add_element("preference")
1841
                _xmlpref.add_element("scanner_name", pref_name)
1842
                _xmlpref.add_element("value", str(pref_value))
1843
1844
        return self._send_xml_command(cmd)
1845