How to use the aenum.extend_enum function in aenum

To help you get started, we’ve selected a few aenum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JarryShaw / PyPCAPKit / pcapkit / const / ipv4 / tos_rel.py View on Github external
def _missing_(cls, value):
        """Lookup function used when value is not found."""
        if not (isinstance(value, int) and 0 <= value <= 1):
            raise ValueError('%r is not a valid %s' % (value, cls.__name__))
        extend_enum(cls, 'Unassigned_%d' % value, value)
        return cls(value)
github JarryShaw / PyPCAPKit / pcapkit / const / hip / parameter.py View on Github external
return cls(value)
        if 61634 <= value <= 61696:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 61698 <= value <= 63660:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 63662 <= value <= 63424:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 63426 <= value <= 63997:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 63999 <= value <= 64001:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 64003 <= value <= 64010:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 64012 <= value <= 64016:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 64018 <= value <= 65497:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
github JarryShaw / PyPCAPKit / pcapkit / const / ipv4 / router_alert.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return RouterAlert(key)
        if key not in RouterAlert._member_map_:  # pylint: disable=no-member
            extend_enum(RouterAlert, key, default)
        return RouterAlert[key]
github JarryShaw / PyPCAPKit / pcapkit / const / arp / operation.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return Operation(key)
        if key not in Operation._member_map_:  # pylint: disable=no-member
            extend_enum(Operation, key, default)
        return Operation[key]
github JarryShaw / PyPCAPKit / pcapkit / const / ipv6 / routing.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return Routing(key)
        if key not in Routing._member_map_:  # pylint: disable=no-member
            extend_enum(Routing, key, default)
        return Routing[key]
github JarryShaw / PyPCAPKit / pcapkit / const / hip / hi_algorithm.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return HIAlgorithm(key)
        if key not in HIAlgorithm._member_map_:  # pylint: disable=no-member
            extend_enum(HIAlgorithm, key, default)
        return HIAlgorithm[key]
github JarryShaw / PyPCAPKit / pcapkit / const / ipv4 / tos_thr.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return ToSThroughput(key)
        if key not in ToSThroughput._member_map_:  # pylint: disable=no-member
            extend_enum(ToSThroughput, key, default)
        return ToSThroughput[key]
github JarryShaw / PyPCAPKit / pcapkit / const / ipv4 / protection_authority.py View on Github external
def _missing_(cls, value):
        """Lookup function used when value is not found."""
        if not (isinstance(value, int) and 0 <= value <= 7):
            raise ValueError('%r is not a valid %s' % (value, cls.__name__))
        extend_enum(cls, 'Unassigned_%d' % value, value)
        return cls(value)
github JarryShaw / PyPCAPKit / pcapkit / const / ftp / return_code.py View on Github external
def get(key, default=-1):
        """Backport support for original codes."""
        if isinstance(key, int):
            return ReturnCode(key)
        if key not in ReturnCode._member_map_:  # pylint: disable=no-member
            extend_enum(ReturnCode, key, default)
        return ReturnCode[key]
github JarryShaw / PyPCAPKit / pcapkit / const / ipv6 / router_alert.py View on Github external
def _missing_(cls, value):
        """Lookup function used when value is not found."""
        if not (isinstance(value, int) and 0 <= value <= 65535):
            raise ValueError('%r is not a valid %s' % (value, cls.__name__))
        if 70 <= value <= 65502:
            #: Unassigned
            extend_enum(cls, 'Unassigned_%d' % value, value)
            return cls(value)
        if 65503 <= value <= 65534:
            #: Reserved for experimental use [:rfc:`5350`]
            extend_enum(cls, 'Reserved for experimental use_%d' % value, value)
            return cls(value)
        return super()._missing_(value)

aenum

Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants

BSD-2-Clause
Latest version published 10 months ago

Package Health Score

78 / 100
Full package analysis