Code Duplication    Length = 14-14 lines in 2 locations

gvm/protocols/gmpv7.py 1 location

@@ 274-287 (lines=14) @@
271
    USERNAME_SSH_KEY = 'usk'
272
273
274
def get_credential_type_from_string(
275
    credential_type: Optional[str]
276
) -> Optional[CredentialType]:
277
    """ Convert a credential type string into a CredentialType instance
278
    """
279
    if not credential_type:
280
        return None
281
282
    try:
283
        return CredentialType[credential_type.upper()]
284
    except KeyError:
285
        raise InvalidArgument(
286
            argument='credential_type',
287
            function=get_credential_type_from_string.__name__,
288
        )
289
290

gvm/protocols/gmpv8.py 1 location

@@ 239-252 (lines=14) @@
236
    PASSWORD_ONLY = 'pw'
237
238
239
def get_credential_type_from_string(
240
    credential_type: Optional[str]
241
) -> Optional[CredentialType]:
242
    """ Convert a credential type string into a CredentialType instance
243
    """
244
    if not credential_type:
245
        return None
246
247
    try:
248
        return CredentialType[credential_type.upper()]
249
    except KeyError:
250
        raise InvalidArgument(
251
            argument='credential_type',
252
            function=get_credential_type_from_string.__name__,
253
        )
254
255