Code Duplication    Length = 34-34 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 433-466 (lines=34) @@
430
    ALEMBA_VFIRE = "Alemba vFire"
431
432
433
def get_alert_method_from_string(
434
    alert_method: Optional[str],
435
) -> Optional[AlertMethod]:
436
    """Convert an alert method string into a AlertCondition instance"""
437
    if not alert_method:
438
        return None
439
440
    alert_method = alert_method.upper()
441
442
    if alert_method == 'START TASK':
443
        return AlertMethod.START_TASK
444
445
    if alert_method == 'HTTP GET':
446
        return AlertMethod.HTTP_GET
447
448
    if alert_method == 'SOURCEFIRE CONNECTOR':
449
        return AlertMethod.SOURCEFIRE_CONNECTOR
450
451
    if alert_method == 'VERINICE CONNECTOR':
452
        return AlertMethod.VERINICE_CONNECTOR
453
454
    if alert_method == 'TIPPINGPOINT SMS':
455
        return AlertMethod.TIPPINGPOINT
456
457
    if alert_method == 'ALEMBA VFIRE':
458
        return AlertMethod.ALEMBA_VFIRE
459
460
    try:
461
        return AlertMethod[alert_method]
462
    except KeyError:
463
        raise InvalidArgument(
464
            argument='alert_method',
465
            function=get_alert_method_from_string.__name__,
466
        ) from None
467
468
469
class ScannerType(Enum):

gvm/protocols/gmpv9/types.py 1 location

@@ 325-358 (lines=34) @@
322
    ALEMBA_VFIRE = "Alemba vFire"
323
324
325
def get_alert_method_from_string(
326
    alert_method: Optional[str],
327
) -> Optional[AlertMethod]:
328
    """Convert an alert method string into a AlertCondition instance"""
329
    if not alert_method:
330
        return None
331
332
    alert_method = alert_method.upper()
333
334
    if alert_method == 'START TASK':
335
        return AlertMethod.START_TASK
336
337
    if alert_method == 'HTTP GET':
338
        return AlertMethod.HTTP_GET
339
340
    if alert_method == 'SOURCEFIRE CONNECTOR':
341
        return AlertMethod.SOURCEFIRE_CONNECTOR
342
343
    if alert_method == 'VERINICE CONNECTOR':
344
        return AlertMethod.VERINICE_CONNECTOR
345
346
    if alert_method == 'TIPPINGPOINT SMS':
347
        return AlertMethod.TIPPINGPOINT
348
349
    if alert_method == 'ALEMBA VFIRE':
350
        return AlertMethod.ALEMBA_VFIRE
351
352
    try:
353
        return AlertMethod[alert_method]
354
    except KeyError:
355
        raise InvalidArgument(
356
            argument='alert_method',
357
            function=get_alert_method_from_string.__name__,
358
        ) from None
359
360
361
class FilterType(Enum):