Code Duplication    Length = 15-17 lines in 2 locations

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

@@ 368-384 (lines=17) @@
365
            if community:
366
                cmd.add_element("community", community)
367
368
            if privacy_algorithm is not None or privacy_password:
369
                _xmlprivacy = cmd.add_element("privacy")
370
371
                if privacy_algorithm is not None:
372
                    if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm):
373
                        raise InvalidArgumentType(
374
                            function=self.create_credential.__name__,
375
                            argument='privacy_algorithm',
376
                            arg_type=SnmpPrivacyAlgorithm.__name__,
377
                        )
378
379
                    _xmlprivacy.add_element(
380
                        "algorithm", privacy_algorithm.value
381
                    )
382
383
                if privacy_password:
384
                    _xmlprivacy.add_element("password", privacy_password)
385
386
        if credential_type == CredentialType.PGP_ENCRYPTION_KEY:
387
            if not public_key:
@@ 592-606 (lines=15) @@
589
        if community:
590
            cmd.add_element("community", community)
591
592
        if privacy_algorithm is not None or privacy_password is not None:
593
            _xmlprivacy = cmd.add_element("privacy")
594
595
            if privacy_algorithm is not None:
596
                if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm):
597
                    raise InvalidArgumentType(
598
                        function=self.modify_credential.__name__,
599
                        argument='privacy_algorithm',
600
                        arg_type=SnmpPrivacyAlgorithm.__name__,
601
                    )
602
603
                _xmlprivacy.add_element("algorithm", privacy_algorithm.value)
604
605
            if privacy_password is not None:
606
                _xmlprivacy.add_element("password", privacy_password)
607
608
        if public_key:
609
            _xmlkey = cmd.add_element("key")