Code Duplication    Length = 22-24 lines in 3 locations

gvm/protocols/gmpv7/gmpv7.py 3 locations

@@ 5110-5133 (lines=24) @@
5107
        if name:
5108
            cmd.add_element("name", name)
5109
5110
        if resource_id or resource_type:
5111
            if not resource_id:
5112
                raise RequiredArgument(
5113
                    function=self.modify_permission.__name__,
5114
                    argument='resource_id',
5115
                )
5116
5117
            if not resource_type:
5118
                raise RequiredArgument(
5119
                    function=self.modify_permission.__name__,
5120
                    argument='resource_type',
5121
                )
5122
5123
            if not isinstance(resource_type, self.types.EntityType):
5124
                raise InvalidArgumentType(
5125
                    function=self.modify_permission.__name__,
5126
                    argument='resource_type',
5127
                    arg_type=self.types.EntityType.__name__,
5128
                )
5129
5130
            _xmlresource = cmd.add_element(
5131
                "resource", attrs={"id": resource_id}
5132
            )
5133
            _xmlresource.add_element("type", resource_type.value)
5134
5135
        if subject_id or subject_type:
5136
            if not subject_id:
@@ 1138-1161 (lines=24) @@
1135
        if comment:
1136
            cmd.add_element("comment", comment)
1137
1138
        if resource_id or resource_type:
1139
            if not resource_id:
1140
                raise RequiredArgument(
1141
                    function=self.create_permission.__name__,
1142
                    argument='resource_id',
1143
                )
1144
1145
            if not resource_type:
1146
                raise RequiredArgument(
1147
                    function=self.create_permission.__name__,
1148
                    argument='resource_type',
1149
                )
1150
1151
            if not isinstance(resource_type, self.types.EntityType):
1152
                raise InvalidArgumentType(
1153
                    function=self.create_permission.__name__,
1154
                    argument='resource_type',
1155
                    arg_type=self.types.EntityType.__name__,
1156
                )
1157
1158
            _xmlresource = cmd.add_element(
1159
                "resource", attrs={"id": resource_id}
1160
            )
1161
            _xmlresource.add_element("type", resource_type.value)
1162
1163
        return self._send_xml_command(cmd)
1164
@@ 5622-5643 (lines=22) @@
5619
        if active is not None:
5620
            cmd.add_element("active", _to_bool(active))
5621
5622
        if resource_id or resource_type:
5623
            if not resource_id:
5624
                raise RequiredArgument(
5625
                    function=self.modify_tag.__name__, argument='resource_id'
5626
                )
5627
5628
            if not resource_type:
5629
                raise RequiredArgument(
5630
                    function=self.modify_tag.__name__, argument='resource_type'
5631
                )
5632
5633
            if not isinstance(resource_type, self.types.EntityType):
5634
                raise InvalidArgumentType(
5635
                    function=self.modify_tag.__name__,
5636
                    argument='resource_type',
5637
                    arg_type=self.types.EntityType.__name__,
5638
                )
5639
5640
            _xmlresource = cmd.add_element(
5641
                "resource", attrs={"id": resource_id}
5642
            )
5643
            _xmlresource.add_element("type", resource_type.value)
5644
5645
        return self._send_xml_command(cmd)
5646