Code Duplication    Length = 15-17 lines in 2 locations

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

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