# -*- coding: utf-8 -*-"""Option Classes====================.. module:: pcapkit.vendor.ipv4.option_classThis module contains the vendor crawler for **Option Classes**,which is automatically generating :class:`pcapkit.const.ipv4.option_class.OptionClass`."""importcollectionsimportsysfromtypingimportTYPE_CHECKINGfrompcapkit.vendor.defaultimportVendorifTYPE_CHECKING:fromcollectionsimportCounter__all__=['OptionClass']#: Option class registry.DATA={0:'control',1:'reserved for future use',2:'debugging and measurement',3:'reserved for future use',}# type: dict[int, str]
[docs]classOptionClass(Vendor):"""Option Classes"""#: Value limit checker.sFLAG='isinstance(value, int) and 0 <= value <= 3'defrequest(self)->'dict[int, str]':# type: ignore[override] # pylint: disable=arguments-differ"""Fetch registry data. Returns: Registry data (:data:`~pcapkit.vendor.ipv4.option_class.DATA`). """returnDATAdefcount(self,data:'dict[int, str]')->'Counter[str]':# type: ignore[override]"""Count field records. Args: data: Registry data. Returns: Field recordings. """returncollections.Counter(map(self.safe_name,data.values()))defprocess(self,data:'dict[int, str]')->'tuple[list[str], list[str]]':# type: ignore[override]"""Process registry data. Args: data: Registry data. Returns: Enumeration fields and missing fields. """enum=[]# type: list[str]miss=["return extend_enum(cls, 'Unassigned_%d' % value, value)",]forcode,nameindata.items():renm=self.rename(name,code)# type: ignore[arg-type]enum.append(f"{renm} = {code}".ljust(76))returnenum,miss