Code Duplication    Length = 21-21 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 306-326 (lines=21) @@
303
    VALUE = "value"  # Group or subgroup column value
304
305
306
def get_aggregate_statistic_from_string(
307
    aggregate_statistic: Optional[str],
308
) -> Optional[AggregateStatistic]:
309
    """
310
    Convert a aggregate statistic string to an actual AggregateStatistic
311
    instance.
312
313
    Arguments:
314
        aggregate_statistic: Aggregate statistic string to convert to a
315
            AggregateStatistic
316
    """
317
    if not aggregate_statistic:
318
        return None
319
320
    try:
321
        return AggregateStatistic[aggregate_statistic.upper()]
322
    except KeyError:
323
        raise InvalidArgument(
324
            argument='aggregate_statistic',
325
            function=get_aggregate_statistic_from_string.__name__,
326
        ) from None
327
328
329
class AlertEvent(Enum):

gvm/protocols/gmpv9/types.py 1 location

@@ 126-146 (lines=21) @@
123
    VALUE = "value"  # Group or subgroup column value
124
125
126
def get_aggregate_statistic_from_string(
127
    aggregate_statistic: Optional[str],
128
) -> Optional[AggregateStatistic]:
129
    """
130
    Convert a aggregate statistic string to an actual AggregateStatistic
131
    instance.
132
133
    Arguments:
134
        aggregate_statistic: Aggregate statistic string to convert to a
135
            AggregateStatistic
136
    """
137
    if not aggregate_statistic:
138
        return None
139
140
    try:
141
        return AggregateStatistic[aggregate_statistic.upper()]
142
    except KeyError:
143
        raise InvalidArgument(
144
            argument='aggregate_statistic',
145
            function=get_aggregate_statistic_from_string.__name__,
146
        ) from None
147
148
149
class EntityType(Enum):