Code Duplication    Length = 18-18 lines in 2 locations

gvm/protocols/gmpv9/types.py 1 location

@@ 520-537 (lines=18) @@
517
    SCAN = "scan"
518
519
520
def __get_usage_type_from_string(
521
    usage_type: Optional[str],
522
) -> Optional[_UsageType]:
523
    """Convert a usage type string to an actual _UsageType instance
524
525
    Arguments:
526
        entity_type: Usage type string to convert to a _UsageType
527
    """
528
    if not usage_type:
529
        return None
530
531
    try:
532
        return _UsageType[usage_type.upper()]
533
    except KeyError:
534
        raise InvalidArgument(
535
            argument='usage_type',
536
            function=__get_usage_type_from_string.__name__,
537
        ) from None
538

gvm/protocols/gmpv208/types.py 1 location

@@ 272-289 (lines=18) @@
269
    SCAN = "scan"
270
271
272
def __get_usage_type_from_string(
273
    usage_type: Optional[str],
274
) -> Optional[_UsageType]:
275
    """Convert a usage type string to an actual _UsageType instance
276
277
    Arguments:
278
        entity_type: Usage type string to convert to a _UsageType
279
    """
280
    if not usage_type:
281
        return None
282
283
    try:
284
        return _UsageType[usage_type.upper()]
285
    except KeyError:
286
        raise InvalidArgument(
287
            argument='usage_type',
288
            function=__get_usage_type_from_string.__name__,
289
        ) from None
290
291
292
class AggregateStatistic(Enum):