Code Duplication    Length = 17-17 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 725-741 (lines=17) @@
722
    REVERSE = "reverse"
723
724
725
def get_hosts_ordering_from_string(
726
    hosts_ordering: Optional[str],
727
) -> Optional[HostsOrdering]:
728
    """Convert a hosts ordering string to an actual HostsOrdering instance
729
730
    Arguments:
731
        hosts_ordering: Host ordering string to convert to a HostsOrdering
732
    """
733
    if not hosts_ordering:
734
        return None
735
    try:
736
        return HostsOrdering[hosts_ordering.upper()]
737
    except KeyError:
738
        raise InvalidArgument(
739
            argument='hosts_ordering',
740
            function=get_hosts_ordering_from_string.__name__,
741
        ) from None
742
743
744
class PermissionSubjectType(Enum):

gvm/protocols/gmpv7/types.py 1 location

@@ 465-481 (lines=17) @@
462
    REVERSE = "reverse"
463
464
465
def get_hosts_ordering_from_string(
466
    hosts_ordering: Optional[str],
467
) -> Optional[HostsOrdering]:
468
    """Convert a hosts ordering string to an actual HostsOrdering instance
469
470
    Arguments:
471
        hosts_ordering: Host ordering string to convert to a HostsOrdering
472
    """
473
    if not hosts_ordering:
474
        return None
475
    try:
476
        return HostsOrdering[hosts_ordering.upper()]
477
    except KeyError:
478
        raise InvalidArgument(
479
            argument='hosts_ordering',
480
            function=get_hosts_ordering_from_string.__name__,
481
        ) from None
482
483
484
class InfoType(Enum):