Code Duplication    Length = 14-14 lines in 3 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 566-579 (lines=14) @@
563
    PASSWORD_ONLY = 'pw'
564
565
566
def get_credential_type_from_string(
567
    credential_type: Optional[str],
568
) -> Optional[CredentialType]:
569
    """Convert a credential type string into a CredentialType instance"""
570
    if not credential_type:
571
        return None
572
573
    try:
574
        return CredentialType[credential_type.upper()]
575
    except KeyError:
576
        raise InvalidArgument(
577
            argument='credential_type',
578
            function=get_credential_type_from_string.__name__,
579
        ) from None
580
581
582
class TicketStatus(Enum):

gvm/protocols/gmpv7/types.py 1 location

@@ 303-316 (lines=14) @@
300
    USERNAME_SSH_KEY = 'usk'
301
302
303
def get_credential_type_from_string(
304
    credential_type: Optional[str],
305
) -> Optional[CredentialType]:
306
    """Convert a credential type string into a CredentialType instance"""
307
    if not credential_type:
308
        return None
309
310
    try:
311
        return CredentialType[credential_type.upper()]
312
    except KeyError:
313
        raise InvalidArgument(
314
            argument='credential_type',
315
            function=get_credential_type_from_string.__name__,
316
        ) from None
317
318
319
class EntityType(Enum):

gvm/protocols/gmpv8/types.py 1 location

@@ 253-266 (lines=14) @@
250
    PASSWORD_ONLY = 'pw'
251
252
253
def get_credential_type_from_string(
254
    credential_type: Optional[str],
255
) -> Optional[CredentialType]:
256
    """Convert a credential type string into a CredentialType instance"""
257
    if not credential_type:
258
        return None
259
260
    try:
261
        return CredentialType[credential_type.upper()]
262
    except KeyError:
263
        raise InvalidArgument(
264
            argument='credential_type',
265
            function=get_credential_type_from_string.__name__,
266
        ) from None
267
268
269
class TicketStatus(Enum):