Code Duplication    Length = 24-24 lines in 2 locations

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 865-888 (lines=24) @@
862
        cmd.add_element("copy", group_id)
863
        return self._send_xml_command(cmd)
864
865
    def create_host(self, name: str, *, comment: Optional[str] = None) -> Any:
866
        """Create a new host asset
867
868
        Arguments:
869
            name: Name for the new host asset
870
            comment: Comment for the new host asset
871
872
        Returns:
873
            The response. See :py:meth:`send_command` for details.
874
        """
875
        if not name:
876
            raise RequiredArgument(
877
                function=self.create_host.__name__, argument='name'
878
            )
879
880
        cmd = XmlCommand("create_asset")
881
        asset = cmd.add_element("asset")
882
        asset.add_element("type", "host")  # ignored for gmp7, required for gmp8
883
        asset.add_element("name", name)
884
885
        if comment:
886
            asset.add_element("comment", comment)
887
888
        return self._send_xml_command(cmd)
889
890
    def create_note(
891
        self,

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 3446-3469 (lines=24) @@
3443
        cmd.add_element("copy", group_id)
3444
        return self._send_xml_command(cmd)
3445
3446
    def create_host(self, name: str, *, comment: Optional[str] = None) -> Any:
3447
        """Create a new host asset
3448
3449
        Arguments:
3450
            name: Name for the new host asset
3451
            comment: Comment for the new host asset
3452
3453
        Returns:
3454
            The response. See :py:meth:`send_command` for details.
3455
        """
3456
        if not name:
3457
            raise RequiredArgument(
3458
                function=self.create_host.__name__, argument='name'
3459
            )
3460
3461
        cmd = XmlCommand("create_asset")
3462
        asset = cmd.add_element("asset")
3463
        asset.add_element("type", "host")  # ignored for gmp7, required for gmp8
3464
        asset.add_element("name", name)
3465
3466
        if comment:
3467
            asset.add_element("comment", comment)
3468
3469
        return self._send_xml_command(cmd)
3470
3471
    def create_note(
3472
        self,