# -*- coding: utf-8 -*-"""CGA Extension Type Tags=============================.. module:: pcapkit.vendor.mh.cga_typeThis module contains the vendor crawler for **CGA Extension Type Tags**,which is automatically generating :class:`pcapkit.const.mh.cga_type.CGAType`."""importcsvimportreimportsysfrompcapkit.vendor.defaultimportVendor__all__=['CGAType']
[docs]classCGAType(Vendor):"""CGA Extension Type Tags"""#: Value limit checker.FLAG='isinstance(value, int) and 0 <= value <= 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF'#: Link to registry.LINK='https://www.iana.org/assignments/cga-message-types/cga-message-types-1.csv'defprocess(self,data:'list[str]')->'tuple[list[str], list[str]]':"""Process CSV data. Args: data: CSV data. Returns: Enumeration fields and missing fields. """reader=csv.reader(data)next(reader)# headerenum=[]# type: list[str]miss=["return extend_enum(cls, 'Tag_%s' % ('_'.join(__import__('textwrap').wrap('%032x' % value, 4))), value)",]foriteminreader:long=item[0]rfcs=item[1]temp=[]# type: list[str]forrfcinfilter(None,re.split(r'\[|\]',rfcs)):if'RFC'inrfcandre.match(r'\d+',rfc[3:]):# temp.append(f'[{rfc[:3]} {rfc[3:]}]')temp.append(f'[:rfc:`{rfc[3:]}`]')else:temp.append(f'[{rfc}]'.replace('_',' '))tmp1=f" {''.join(temp)}"ifrfcselse''name='Tag_%s'%long[2:].replace(' ','_')desc=self.wrap_comment(f'{long}{tmp1}')pres=f"{name} = {long.replace(' ','_')}"sufs=f'#: {desc}'# if len(pres) > 74:# sufs = f"\n{' '*80}{sufs}"# enum.append(f'{pres.ljust(76)}{sufs}')enum.append(f'{sufs}\n{pres}')returnenum,miss