Source code for pcapkit.const.ipv4.classification_level
# -*- coding: utf-8 -*-# pylint: disable=line-too-long,consider-using-f-string"""Classification Level Encodings====================================.. module:: pcapkit.const.ipv4.classification_levelThis module contains the constant enumeration for **Classification Level Encodings**,which is automatically generated from :class:`pcapkit.vendor.ipv4.classification_level.ClassificationLevel`."""fromaenumimportIntEnum,extend_enum__all__=['ClassificationLevel']
[docs]classClassificationLevel(IntEnum):"""[ClassificationLevel] Classification Level Encodings"""Reserved_4=0b00000001Top_Secret=0b00111101Secret=0b01011010Confidential=0b10010110Reserved_3=0b01100110Reserved_2=0b11001100Unclassified=0b10101011Reserved_1=0b11110001@staticmethoddefget(key:'int | str',default:'int'=-1)->'ClassificationLevel':"""Backport support for original codes. Args: key: Key to get enum item. default: Default value if not found. :meta private: """ifisinstance(key,int):returnClassificationLevel(key)ifkeynotinClassificationLevel._member_map_:# pylint: disable=no-memberreturnextend_enum(ClassificationLevel,key,default)returnClassificationLevel[key]# type: ignore[misc]
[docs]@classmethoddef_missing_(cls,value:'int')->'ClassificationLevel':"""Lookup function used when value is not found. Args: value: Value to get enum item. """ifnot(isinstance(value,int)and0b00000000<=value<=0b11111111):raiseValueError('%r is not a valid %s'%(value,cls.__name__))temp=bin(value)[2:].upper().zfill(8)returnextend_enum(cls,'Unassigned_0b%s'%(temp[:4]+'_'+temp[4:]),value)