Code Duplication    Length = 15-15 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 675-689 (lines=15) @@
672
    HOST = 'host'
673
674
675
def get_asset_type_from_string(
676
    asset_type: Optional[str],
677
) -> Optional[AssetType]:
678
    if not asset_type:
679
        return None
680
681
    if asset_type == 'os':
682
        return AssetType.OPERATING_SYSTEM
683
684
    try:
685
        return AssetType[asset_type.upper()]
686
    except KeyError:
687
        raise InvalidArgument(
688
            argument='asset_type', function=get_asset_type_from_string.__name__
689
        ) from None
690
691
692
class CredentialFormat(Enum):

gvm/protocols/gmpv7/types.py 1 location

@@ 252-266 (lines=15) @@
249
    HOST = 'host'
250
251
252
def get_asset_type_from_string(
253
    asset_type: Optional[str],
254
) -> Optional[AssetType]:
255
    if not asset_type:
256
        return None
257
258
    if asset_type == 'os':
259
        return AssetType.OPERATING_SYSTEM
260
261
    try:
262
        return AssetType[asset_type.upper()]
263
    except KeyError:
264
        raise InvalidArgument(
265
            argument='asset_type', function=get_asset_type_from_string.__name__
266
        ) from None
267
268
269
class CredentialFormat(Enum):