Code Duplication    Length = 30-30 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 383-412 (lines=30) @@
380
    FILTER_COUNT_AT_LEAST = 'Filter count at least'
381
382
383
def get_alert_condition_from_string(
384
    alert_condition: Optional[str],
385
) -> Optional[AlertCondition]:
386
    """Convert an alert condition string into a AlertCondition instance"""
387
    if not alert_condition:
388
        return None
389
390
    alert_condition = alert_condition.lower()
391
392
    if alert_condition == 'error':
393
        return AlertCondition.ERROR
394
395
    if alert_condition == 'always':
396
        return AlertCondition.ALWAYS
397
398
    if alert_condition == 'filter count changed':
399
        return AlertCondition.FILTER_COUNT_CHANGED
400
401
    if alert_condition == 'filter count at least':
402
        return AlertCondition.FILTER_COUNT_AT_LEAST
403
404
    if alert_condition == 'severity at least':
405
        return AlertCondition.SEVERITY_AT_LEAST
406
407
    if alert_condition == 'severity changed':
408
        return AlertCondition.SEVERITY_CHANGED
409
410
    raise InvalidArgument(
411
        argument='alert_condition',
412
        function=get_alert_condition_from_string.__name__,
413
    )
414
415

gvm/protocols/gmpv9/types.py 1 location

@@ 275-304 (lines=30) @@
272
    FILTER_COUNT_AT_LEAST = 'Filter count at least'
273
274
275
def get_alert_condition_from_string(
276
    alert_condition: Optional[str],
277
) -> Optional[AlertCondition]:
278
    """Convert an alert condition string into a AlertCondition instance"""
279
    if not alert_condition:
280
        return None
281
282
    alert_condition = alert_condition.lower()
283
284
    if alert_condition == 'error':
285
        return AlertCondition.ERROR
286
287
    if alert_condition == 'always':
288
        return AlertCondition.ALWAYS
289
290
    if alert_condition == 'filter count changed':
291
        return AlertCondition.FILTER_COUNT_CHANGED
292
293
    if alert_condition == 'filter count at least':
294
        return AlertCondition.FILTER_COUNT_AT_LEAST
295
296
    if alert_condition == 'severity at least':
297
        return AlertCondition.SEVERITY_AT_LEAST
298
299
    if alert_condition == 'severity changed':
300
        return AlertCondition.SEVERITY_CHANGED
301
302
    raise InvalidArgument(
303
        argument='alert_condition',
304
        function=get_alert_condition_from_string.__name__,
305
    )
306
307