From 1285d06d7fc17b8e4c7d2c335460309231a20c32 Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Sun, 27 Sep 2026 17:51:20 -0400 Subject: [PATCH] refactor(const,vendor): apply the mint/unmint criterion ruling to 82 registries (#775) - classify every one of the 89 `_missing_` bodies still calling `extend_enum` against the owner's ruling on #775/#847: a final concrete assigned name mints, a notation for the reader (Unassigned/Reserved/Deprecated/etc.) unmints - convert 82 registries wholly and two more (`EtherType`, `Socket`) partially, 172 branches total, from `extend_enum` to `_unregistered_member`, in both the vendor crawler and the generated const file, following #838's/#858's precedent; proved a 5-file sample (Form-A and Form-B crawlers, both mixed registries) regenerates byte-identically - leave 89-82=7 untouched: `CGAType`'s mint is not an IANA-style range at all, and 6 files sit on classes without `EnumRegistry` yet (`AppType` and friends), tracked separately by #860 pending #859 - extend `tests/const/test_const_enum_no_mint.py` with the ruling-derived registry lists and behavioural/source coverage for all 82+2, correct its stale "~92 still mint" docstring to the measured 89, and fix collateral breakage in three sibling test files and `tests/vendor/test_ipx_socket_ unit.py` that pinned the pre-ruling mint behaviour - fix the last two collateral pins the ruling invalidates, in files the first pass missed and CI caught: `tests/corekit/test_fields_numbers_unassigned_ enum.py` expected `BlockType(0x0bad0bad).name == 'Reserved_0bad0bad'`, now `Reserved` with the value asserted explicitly since the name no longer carries it; and `tests/protocols/misc/test_pcapng_unit.py` read `FilterType.Unassigned_0` by attribute, a member that existed only because of the import-time mint at `pcapkit/protocols/misc/pcapng.py:4593` which this change removes Build: plain `unittest` on tests/const (179), tests/vendor (86), tests/corekit/test_fields_numbers_unassigned_enum.py (11) and tests/protocols/misc/test_pcapng_unit.py (92 + 1 skipped) all green; both newly-fixed files fail with their const file reverted to main. --- pcapkit/const/esp/cipher.py | 6 +- pcapkit/const/esp/integrity.py | 6 +- pcapkit/const/hip/eddsa_curve.py | 4 +- pcapkit/const/hip/group.py | 4 +- pcapkit/const/hip/packet.py | 8 +- pcapkit/const/hip/parameter.py | 98 ++-- pcapkit/const/http/error_code.py | 5 +- pcapkit/const/http/frame.py | 6 +- pcapkit/const/http/setting.py | 8 +- pcapkit/const/ipv4/classification_level.py | 5 +- pcapkit/const/ipv4/option_class.py | 4 +- pcapkit/const/ipv4/option_number.py | 4 +- pcapkit/const/ipv4/protection_authority.py | 4 +- pcapkit/const/ipv4/qs_function.py | 4 +- pcapkit/const/ipv4/router_alert.py | 6 +- pcapkit/const/ipv4/tos_del.py | 4 +- pcapkit/const/ipv4/tos_ecn.py | 4 +- pcapkit/const/ipv4/tos_pre.py | 4 +- pcapkit/const/ipv4/tos_rel.py | 4 +- pcapkit/const/ipv4/tos_thr.py | 4 +- pcapkit/const/ipv4/ts_flag.py | 4 +- pcapkit/const/ipv6/option.py | 4 +- pcapkit/const/ipv6/option_action.py | 4 +- pcapkit/const/ipv6/qs_function.py | 4 +- pcapkit/const/ipv6/router_alert.py | 6 +- pcapkit/const/ipv6/routing.py | 4 +- pcapkit/const/ipv6/seed_id.py | 4 +- pcapkit/const/ipv6/smf_dpd_mode.py | 4 +- pcapkit/const/ipv6/tagger_id.py | 4 +- pcapkit/const/ipx/packet.py | 4 +- pcapkit/const/ipx/socket.py | 8 +- pcapkit/const/l2tp/type.py | 4 +- pcapkit/const/mh/access_type.py | 4 +- pcapkit/const/mh/ack_status_code.py | 6 +- pcapkit/const/mh/ani_suboption.py | 4 +- pcapkit/const/mh/auth_subtype.py | 4 +- pcapkit/const/mh/binding_error.py | 4 +- pcapkit/const/mh/binding_revocation.py | 4 +- pcapkit/const/mh/cga_extension.py | 8 +- pcapkit/const/mh/cga_sec.py | 4 +- pcapkit/const/mh/dhcp_support_mode.py | 4 +- pcapkit/const/mh/dns_status_code.py | 6 +- pcapkit/const/mh/dsmip6_tls_packet.py | 6 +- pcapkit/const/mh/dsmipv6_home_address.py | 6 +- pcapkit/const/mh/enumerating_algorithm.py | 4 +- pcapkit/const/mh/fb_ack_status.py | 6 +- pcapkit/const/mh/fb_action.py | 6 +- pcapkit/const/mh/fb_indication_trigger.py | 6 +- pcapkit/const/mh/fb_type.py | 4 +- pcapkit/const/mh/flow_id_status.py | 8 +- pcapkit/const/mh/flow_id_suboption.py | 6 +- pcapkit/const/mh/handoff_type.py | 4 +- pcapkit/const/mh/handover_ack_status.py | 6 +- pcapkit/const/mh/handover_initiate_status.py | 4 +- pcapkit/const/mh/home_address_reply.py | 6 +- pcapkit/const/mh/lla_code.py | 4 +- pcapkit/const/mh/lma_mag_suboption.py | 4 +- pcapkit/const/mh/mn_group_id.py | 4 +- pcapkit/const/mh/mn_id_subtype.py | 6 +- pcapkit/const/mh/operator_id.py | 4 +- pcapkit/const/mh/option.py | 4 +- pcapkit/const/mh/packet.py | 4 +- pcapkit/const/mh/qos_attribute.py | 4 +- pcapkit/const/mh/revocation_status_code.py | 6 +- pcapkit/const/mh/revocation_trigger.py | 8 +- pcapkit/const/mh/status_code.py | 6 +- pcapkit/const/mh/traffic_selector.py | 6 +- pcapkit/const/mh/upa_status.py | 6 +- pcapkit/const/mh/upn_reason.py | 4 +- pcapkit/const/pcapng/block_type.py | 12 +- pcapkit/const/pcapng/filter_type.py | 4 +- pcapkit/const/pcapng/hash_algorithm.py | 4 +- pcapkit/const/pcapng/record_type.py | 4 +- pcapkit/const/pcapng/secrets_type.py | 4 +- pcapkit/const/pcapng/verdict_type.py | 4 +- pcapkit/const/reg/ethertype.py | 8 +- pcapkit/const/reg/linktype.py | 4 +- pcapkit/const/reg/transtype.py | 4 +- pcapkit/const/tcp/checksum.py | 4 +- pcapkit/const/tcp/mp_tcp_option.py | 4 +- pcapkit/const/tcp/option.py | 10 +- pcapkit/const/vlan/priority_level.py | 4 +- pcapkit/vendor/esp/cipher.py | 2 +- pcapkit/vendor/esp/integrity.py | 2 +- pcapkit/vendor/hip/eddsa_curve.py | 2 +- pcapkit/vendor/hip/group.py | 2 +- pcapkit/vendor/hip/packet.py | 2 +- pcapkit/vendor/hip/parameter.py | 2 +- pcapkit/vendor/http/error_code.py | 3 +- pcapkit/vendor/http/frame.py | 2 +- pcapkit/vendor/http/setting.py | 2 +- pcapkit/vendor/ipv4/classification_level.py | 3 +- pcapkit/vendor/ipv4/option_class.py | 2 +- pcapkit/vendor/ipv4/option_number.py | 2 +- pcapkit/vendor/ipv4/protection_authority.py | 2 +- pcapkit/vendor/ipv4/qs_function.py | 2 +- pcapkit/vendor/ipv4/router_alert.py | 2 +- pcapkit/vendor/ipv4/tos_del.py | 2 +- pcapkit/vendor/ipv4/tos_ecn.py | 2 +- pcapkit/vendor/ipv4/tos_pre.py | 2 +- pcapkit/vendor/ipv4/tos_rel.py | 2 +- pcapkit/vendor/ipv4/tos_thr.py | 2 +- pcapkit/vendor/ipv4/ts_flag.py | 2 +- pcapkit/vendor/ipv6/option.py | 2 +- pcapkit/vendor/ipv6/option_action.py | 2 +- pcapkit/vendor/ipv6/qs_function.py | 2 +- pcapkit/vendor/ipv6/router_alert.py | 2 +- pcapkit/vendor/ipv6/routing.py | 2 +- pcapkit/vendor/ipv6/seed_id.py | 2 +- pcapkit/vendor/ipv6/smf_dpd_mode.py | 2 +- pcapkit/vendor/ipv6/tagger_id.py | 2 +- pcapkit/vendor/ipx/packet.py | 2 +- pcapkit/vendor/ipx/socket.py | 17 +- pcapkit/vendor/l2tp/type.py | 2 +- pcapkit/vendor/mh/access_type.py | 2 +- pcapkit/vendor/mh/ack_status_code.py | 2 +- pcapkit/vendor/mh/ani_suboption.py | 2 +- pcapkit/vendor/mh/auth_subtype.py | 2 +- pcapkit/vendor/mh/binding_error.py | 2 +- pcapkit/vendor/mh/binding_revocation.py | 2 +- pcapkit/vendor/mh/cga_extension.py | 4 +- pcapkit/vendor/mh/cga_sec.py | 4 +- pcapkit/vendor/mh/dhcp_support_mode.py | 2 +- pcapkit/vendor/mh/dns_status_code.py | 2 +- pcapkit/vendor/mh/dsmip6_tls_packet.py | 2 +- pcapkit/vendor/mh/dsmipv6_home_address.py | 2 +- pcapkit/vendor/mh/enumerating_algorithm.py | 2 +- pcapkit/vendor/mh/fb_ack_status.py | 2 +- pcapkit/vendor/mh/fb_action.py | 2 +- pcapkit/vendor/mh/fb_indication_trigger.py | 2 +- pcapkit/vendor/mh/fb_type.py | 2 +- pcapkit/vendor/mh/flow_id_status.py | 2 +- pcapkit/vendor/mh/flow_id_suboption.py | 2 +- pcapkit/vendor/mh/handoff_type.py | 2 +- pcapkit/vendor/mh/handover_ack_status.py | 2 +- pcapkit/vendor/mh/handover_initiate_status.py | 2 +- pcapkit/vendor/mh/home_address_reply.py | 2 +- pcapkit/vendor/mh/lla_code.py | 2 +- pcapkit/vendor/mh/lma_mag_suboption.py | 2 +- pcapkit/vendor/mh/mn_group_id.py | 2 +- pcapkit/vendor/mh/mn_id_subtype.py | 2 +- pcapkit/vendor/mh/operator_id.py | 2 +- pcapkit/vendor/mh/option.py | 2 +- pcapkit/vendor/mh/packet.py | 2 +- pcapkit/vendor/mh/qos_attribute.py | 2 +- pcapkit/vendor/mh/revocation_status_code.py | 2 +- pcapkit/vendor/mh/revocation_trigger.py | 2 +- pcapkit/vendor/mh/status_code.py | 4 +- pcapkit/vendor/mh/traffic_selector.py | 2 +- pcapkit/vendor/mh/upa_status.py | 2 +- pcapkit/vendor/mh/upn_reason.py | 2 +- pcapkit/vendor/pcapng/block_type.py | 2 +- pcapkit/vendor/pcapng/filter_type.py | 2 +- pcapkit/vendor/pcapng/hash_algorithm.py | 2 +- pcapkit/vendor/pcapng/record_type.py | 2 +- pcapkit/vendor/pcapng/secrets_type.py | 2 +- pcapkit/vendor/pcapng/verdict_type.py | 2 +- pcapkit/vendor/reg/ethertype.py | 19 +- pcapkit/vendor/reg/linktype.py | 2 +- pcapkit/vendor/reg/transtype.py | 2 +- pcapkit/vendor/tcp/checksum.py | 2 +- pcapkit/vendor/tcp/mp_tcp_option.py | 2 +- pcapkit/vendor/tcp/option.py | 2 +- pcapkit/vendor/vlan/priority_level.py | 2 +- tests/const/test_const_enum_builtin_parity.py | 59 +- tests/const/test_const_enum_get.py | 119 +++- tests/const/test_const_enum_no_mint.py | 542 +++++++++++++++++- tests/const/test_const_registry_protocol.py | 19 +- .../test_fields_numbers_unassigned_enum.py | 19 +- tests/protocols/misc/test_pcapng_unit.py | 26 +- tests/vendor/test_ipx_socket_unit.py | 46 +- 171 files changed, 1121 insertions(+), 419 deletions(-) diff --git a/pcapkit/const/esp/cipher.py b/pcapkit/const/esp/cipher.py index e9071f357c..5e76db1f85 100644 --- a/pcapkit/const/esp/cipher.py +++ b/pcapkit/const/esp/cipher.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -230,8 +230,8 @@ def _missing_(cls, value: 'int') -> 'Cipher': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 36 <= value <= 1023: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 1024 <= value <= 65535: #: Reserved for Private Use [:rfc:`7296`] - return extend_enum(cls, 'Reserved_for_Private_Use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Private_Use') return super()._missing_(value) diff --git a/pcapkit/const/esp/integrity.py b/pcapkit/const/esp/integrity.py index 8992c95b2e..950ec45354 100644 --- a/pcapkit/const/esp/integrity.py +++ b/pcapkit/const/esp/integrity.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -119,8 +119,8 @@ def _missing_(cls, value: 'int') -> 'Integrity': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 15 <= value <= 1023: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 1024 <= value <= 65535: #: Reserved for Private Use [:rfc:`7296`] - return extend_enum(cls, 'Reserved_for_Private_Use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Private_Use') return super()._missing_(value) diff --git a/pcapkit/const/hip/eddsa_curve.py b/pcapkit/const/hip/eddsa_curve.py index cab38daacd..f27b3e9849 100644 --- a/pcapkit/const/hip/eddsa_curve.py +++ b/pcapkit/const/hip/eddsa_curve.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -47,5 +47,5 @@ def _missing_(cls, value: 'int') -> 'EdDSACurve': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 5 <= value <= 65535: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/hip/group.py b/pcapkit/const/hip/group.py index ea350ebde4..918ae43d5f 100644 --- a/pcapkit/const/hip/group.py +++ b/pcapkit/const/hip/group.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -68,5 +68,5 @@ def _missing_(cls, value: 'int') -> 'Group': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 12 <= value <= 255: # Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/hip/packet.py b/pcapkit/const/hip/packet.py index 469cfa9dd6..12ddbcf871 100644 --- a/pcapkit/const/hip/packet.py +++ b/pcapkit/const/hip/packet.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -65,11 +65,11 @@ def _missing_(cls, value: 'int') -> 'Packet': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 5 <= value <= 15: # Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 21 <= value <= 31: # Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 33 <= value <= 127: # Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/hip/parameter.py b/pcapkit/const/hip/parameter.py index 7dbf8c26c2..5d52057de7 100644 --- a/pcapkit/const/hip/parameter.py +++ b/pcapkit/const/hip/parameter.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -218,146 +218,146 @@ def _missing_(cls, value: 'int') -> 'Parameter': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0 <= value <= 64: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 66 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 130 <= value <= 192: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 194 <= value <= 256: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 258 <= value <= 320: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 322 <= value <= 384: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 386 <= value <= 448: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 450 <= value <= 510: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 514 <= value <= 576: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 580 <= value <= 607: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 611 <= value <= 640: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 642 <= value <= 704: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 706 <= value <= 714: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 716 <= value <= 767: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 769 <= value <= 831: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 833 <= value <= 896: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 898 <= value <= 929: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 937 <= value <= 949: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 951 <= value <= 960: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 962 <= value <= 2048: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 2050 <= value <= 4094: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4096 <= value <= 4480: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4482 <= value <= 4544: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4546 <= value <= 4576: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4578 <= value <= 4579: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4581 <= value <= 4591: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4593 <= value <= 4600: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4602 <= value <= 4649: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4651 <= value <= 4659: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4661 <= value <= 4679: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4681 <= value <= 4699: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4701 <= value <= 4709: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 4711 <= value <= 7679: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 7681 <= value <= 32767: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 32768 <= value <= 49151: #: Reserved [:rfc:`7401`] - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') if 49152 <= value <= 61504: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 61506 <= value <= 61568: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 61570 <= value <= 61632: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 61634 <= value <= 61696: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 61698 <= value <= 63660: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 63662 <= value <= 63424: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 63426 <= value <= 63997: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 63999 <= value <= 64001: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 64003 <= value <= 64010: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 64012 <= value <= 64016: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 64018 <= value <= 65497: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 65503 <= value <= 65519: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 65521 <= value <= 65535: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/http/error_code.py b/pcapkit/const/http/error_code.py index 368d1ff2e7..f20155fa64 100644 --- a/pcapkit/const/http/error_code.py +++ b/pcapkit/const/http/error_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -76,6 +76,5 @@ def _missing_(cls, value: 'int') -> 'ErrorCode': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0000000E <= value <= 0xFFFFFFFF: #: Unassigned - temp = hex(value)[2:].upper().zfill(8) - return extend_enum(cls, 'Unassigned_0x%s' % (temp[:4]+'_'+temp[4:]), value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/http/frame.py b/pcapkit/const/http/frame.py index f6bc562360..5ef1e8a78c 100644 --- a/pcapkit/const/http/frame.py +++ b/pcapkit/const/http/frame.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -74,8 +74,8 @@ def _missing_(cls, value: 'int') -> 'Frame': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0D <= value <= 0x0F: #: ``Unassigned`` - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(2), value) + return cls._unregistered_member(value, 'Unassigned') if 0x11 <= value <= 0xFF: #: ``Unassigned`` - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(2), value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/http/setting.py b/pcapkit/const/http/setting.py index 7550b4d343..8b70c7ce77 100644 --- a/pcapkit/const/http/setting.py +++ b/pcapkit/const/http/setting.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -72,11 +72,11 @@ def _missing_(cls, value: 'int') -> 'Setting': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x000A <= value <= 0x000F: #: ``Unassigned`` - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Unassigned') if 0x0011 <= value <= 0x4D43: #: ``Unassigned`` - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Unassigned') if 0x4D45 <= value <= 0xFFFF: #: ``Unassigned`` - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/ipv4/classification_level.py b/pcapkit/const/ipv4/classification_level.py index 75f213d077..16d425b22f 100644 --- a/pcapkit/const/ipv4/classification_level.py +++ b/pcapkit/const/ipv4/classification_level.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -46,5 +46,4 @@ def _missing_(cls, value: 'int') -> 'ClassificationLevel': """ if not (isinstance(value, int) and 0b00000000 <= value <= 0b11111111): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - temp = bin(value)[2:].upper().zfill(8) - return extend_enum(cls, 'Unassigned_0b%s' % (temp[:4]+'_'+temp[4:]), value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/option_class.py b/pcapkit/const/ipv4/option_class.py index d8385a6164..8b399171b9 100644 --- a/pcapkit/const/ipv4/option_class.py +++ b/pcapkit/const/ipv4/option_class.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,4 +38,4 @@ def _missing_(cls, value: 'int') -> 'OptionClass': """ if not (isinstance(value, int) and 0 <= value <= 3): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/option_number.py b/pcapkit/const/ipv4/option_number.py index 754345b3a4..7c167206ac 100644 --- a/pcapkit/const/ipv4/option_number.py +++ b/pcapkit/const/ipv4/option_number.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -120,4 +120,4 @@ def _missing_(cls, value: 'int') -> 'OptionNumber': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/protection_authority.py b/pcapkit/const/ipv4/protection_authority.py index 8f0d31fc6f..635d693bc1 100644 --- a/pcapkit/const/ipv4/protection_authority.py +++ b/pcapkit/const/ipv4/protection_authority.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -46,4 +46,4 @@ def _missing_(cls, value: 'int') -> 'ProtectionAuthority': """ if not (isinstance(value, int) and value >= 0): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/qs_function.py b/pcapkit/const/ipv4/qs_function.py index 08881a5c25..1ba0fa2c03 100644 --- a/pcapkit/const/ipv4/qs_function.py +++ b/pcapkit/const/ipv4/qs_function.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'QSFunction': """ if not (isinstance(value, int) and 0 <= value <= 8): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/router_alert.py b/pcapkit/const/ipv4/router_alert.py index 231f4508fd..1f6768601a 100644 --- a/pcapkit/const/ipv4/router_alert.py +++ b/pcapkit/const/ipv4/router_alert.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -233,8 +233,8 @@ def _missing_(cls, value: 'int') -> 'RouterAlert': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 66 <= value <= 65502: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 65503 <= value <= 65534: #: Reserved for experimental use [:rfc:`5350`] - return extend_enum(cls, 'Reserved for experimental use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved for experimental use') return super()._missing_(value) diff --git a/pcapkit/const/ipv4/tos_del.py b/pcapkit/const/ipv4/tos_del.py index 14e32ebdd4..8d2d634f11 100644 --- a/pcapkit/const/ipv4/tos_del.py +++ b/pcapkit/const/ipv4/tos_del.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'ToSDelay': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/tos_ecn.py b/pcapkit/const/ipv4/tos_ecn.py index f033350604..34afff8934 100644 --- a/pcapkit/const/ipv4/tos_ecn.py +++ b/pcapkit/const/ipv4/tos_ecn.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,4 +38,4 @@ def _missing_(cls, value: 'int') -> 'ToSECN': """ if not (isinstance(value, int) and 0b00 <= value <= 0b11): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_0b%s' % bin(value)[2:].zfill(2), value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/tos_pre.py b/pcapkit/const/ipv4/tos_pre.py index 182e259a2b..9cffeb9280 100644 --- a/pcapkit/const/ipv4/tos_pre.py +++ b/pcapkit/const/ipv4/tos_pre.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -46,4 +46,4 @@ def _missing_(cls, value: 'int') -> 'ToSPrecedence': """ if not (isinstance(value, int) and 0b000 <= value <= 0b111): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/tos_rel.py b/pcapkit/const/ipv4/tos_rel.py index c59677b189..dc00762b78 100644 --- a/pcapkit/const/ipv4/tos_rel.py +++ b/pcapkit/const/ipv4/tos_rel.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'ToSReliability': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/tos_thr.py b/pcapkit/const/ipv4/tos_thr.py index da7a64578f..91cb71629e 100644 --- a/pcapkit/const/ipv4/tos_thr.py +++ b/pcapkit/const/ipv4/tos_thr.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'ToSThroughput': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv4/ts_flag.py b/pcapkit/const/ipv4/ts_flag.py index 3f932dc4d5..f89ca8aa55 100644 --- a/pcapkit/const/ipv4/ts_flag.py +++ b/pcapkit/const/ipv4/ts_flag.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -36,4 +36,4 @@ def _missing_(cls, value: 'int') -> 'TSFlag': """ if not (isinstance(value, int) and 0b0000 <= value <= 0b1111): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/option.py b/pcapkit/const/ipv6/option.py index 6f1200f49e..a543f982ad 100644 --- a/pcapkit/const/ipv6/option.py +++ b/pcapkit/const/ipv6/option.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -120,4 +120,4 @@ def _missing_(cls, value: 'int') -> 'Option': """ if not (isinstance(value, int) and 0x00 <= value <= 0xFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(2), value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/option_action.py b/pcapkit/const/ipv6/option_action.py index 5a54cf41f2..7d5ac9671b 100644 --- a/pcapkit/const/ipv6/option_action.py +++ b/pcapkit/const/ipv6/option_action.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,4 +38,4 @@ def _missing_(cls, value: 'int') -> 'OptionAction': """ if not (isinstance(value, int) and 0 <= value <= 3): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/qs_function.py b/pcapkit/const/ipv6/qs_function.py index ee02d867b6..9ed321d0aa 100644 --- a/pcapkit/const/ipv6/qs_function.py +++ b/pcapkit/const/ipv6/qs_function.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'QSFunction': """ if not (isinstance(value, int) and 0 <= value <= 8): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/router_alert.py b/pcapkit/const/ipv6/router_alert.py index ef4f11addd..ecc993129e 100644 --- a/pcapkit/const/ipv6/router_alert.py +++ b/pcapkit/const/ipv6/router_alert.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -245,8 +245,8 @@ def _missing_(cls, value: 'int') -> 'RouterAlert': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 70 <= value <= 65502: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 65503 <= value <= 65534: #: Reserved [:rfc:`9805`] - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') return super()._missing_(value) diff --git a/pcapkit/const/ipv6/routing.py b/pcapkit/const/ipv6/routing.py index 96ba60c2ee..611ae25a92 100644 --- a/pcapkit/const/ipv6/routing.py +++ b/pcapkit/const/ipv6/routing.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -62,5 +62,5 @@ def _missing_(cls, value: 'int') -> 'Routing': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 7 <= value <= 252: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/ipv6/seed_id.py b/pcapkit/const/ipv6/seed_id.py index ba43ef4e2c..d7333613c7 100644 --- a/pcapkit/const/ipv6/seed_id.py +++ b/pcapkit/const/ipv6/seed_id.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,4 +38,4 @@ def _missing_(cls, value: 'int') -> 'SeedID': """ if not (isinstance(value, int) and 0b00 <= value <= 0b11): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_0b%s' % bin(value)[2:].zfill(2), value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/smf_dpd_mode.py b/pcapkit/const/ipv6/smf_dpd_mode.py index 96e085ae01..18e966a284 100644 --- a/pcapkit/const/ipv6/smf_dpd_mode.py +++ b/pcapkit/const/ipv6/smf_dpd_mode.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'SMFDPDMode': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipv6/tagger_id.py b/pcapkit/const/ipv6/tagger_id.py index 1527b829e4..966030508c 100644 --- a/pcapkit/const/ipv6/tagger_id.py +++ b/pcapkit/const/ipv6/tagger_id.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -44,5 +44,5 @@ def _missing_(cls, value: 'int') -> 'TaggerID': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 4 <= value <= 7: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/ipx/packet.py b/pcapkit/const/ipx/packet.py index 8336a0bad2..d697d9508c 100644 --- a/pcapkit/const/ipx/packet.py +++ b/pcapkit/const/ipx/packet.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -55,4 +55,4 @@ def _missing_(cls, value: 'int') -> 'Packet': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/ipx/socket.py b/pcapkit/const/ipx/socket.py index ea692e7ccc..8c8451da6b 100644 --- a/pcapkit/const/ipx/socket.py +++ b/pcapkit/const/ipx/socket.py @@ -77,17 +77,17 @@ def _missing_(cls, value: 'int') -> 'Socket': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0020 <= value <= 0x003F: #: Experimental - return extend_enum(cls, 'Experimental_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Experimental') if 0x0001 <= value <= 0x0BB8: #: Registered by Xerox return extend_enum(cls, 'Registered by Xerox_0x%s' % hex(value)[2:].upper().zfill(4), value) if 0x4000 <= value <= 0x4FFF: #: Dynamically Assigned Socket Numbers - return extend_enum(cls, 'Dynamically Assigned Socket Numbers_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Dynamically Assigned Socket Numbers') if 0x8000 <= value <= 0xFFFF: #: Statically Assigned Socket Numbers - return extend_enum(cls, 'Statically Assigned Socket Numbers_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Statically Assigned Socket Numbers') if 0x0BB9 <= value <= 0xFFFF: #: Dynamically Assigned - return extend_enum(cls, 'Dynamically Assigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Dynamically Assigned') return super()._missing_(value) diff --git a/pcapkit/const/l2tp/type.py b/pcapkit/const/l2tp/type.py index a60a1b84e4..e6e3dcbb01 100644 --- a/pcapkit/const/l2tp/type.py +++ b/pcapkit/const/l2tp/type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'Type': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/access_type.py b/pcapkit/const/mh/access_type.py index 87043d167c..dfb524e63c 100644 --- a/pcapkit/const/mh/access_type.py +++ b/pcapkit/const/mh/access_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -74,5 +74,5 @@ def _missing_(cls, value: 'int') -> 'AccessType': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 14 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/ack_status_code.py b/pcapkit/const/mh/ack_status_code.py index cbca43d486..e5cf91ab69 100644 --- a/pcapkit/const/mh/ack_status_code.py +++ b/pcapkit/const/mh/ack_status_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -50,8 +50,8 @@ def _missing_(cls, value: 'int') -> 'ACKStatusCode': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 133 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/ani_suboption.py b/pcapkit/const/mh/ani_suboption.py index 5eaa20e2c1..d6ee122194 100644 --- a/pcapkit/const/mh/ani_suboption.py +++ b/pcapkit/const/mh/ani_suboption.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -56,5 +56,5 @@ def _missing_(cls, value: 'int') -> 'ANISuboption': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 7 <= value <= 254: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/auth_subtype.py b/pcapkit/const/mh/auth_subtype.py index 664750ac98..6e18e0c4a6 100644 --- a/pcapkit/const/mh/auth_subtype.py +++ b/pcapkit/const/mh/auth_subtype.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -36,4 +36,4 @@ def _missing_(cls, value: 'int') -> 'AuthSubtype': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/binding_error.py b/pcapkit/const/mh/binding_error.py index 17890e49ab..ba7460695a 100644 --- a/pcapkit/const/mh/binding_error.py +++ b/pcapkit/const/mh/binding_error.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -34,4 +34,4 @@ def _missing_(cls, value: 'int') -> 'BindingError': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/binding_revocation.py b/pcapkit/const/mh/binding_revocation.py index 13da8f6b9e..2ecafa3186 100644 --- a/pcapkit/const/mh/binding_revocation.py +++ b/pcapkit/const/mh/binding_revocation.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,5 +41,5 @@ def _missing_(cls, value: 'int') -> 'BindingRevocation': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 3 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/cga_extension.py b/pcapkit/const/mh/cga_extension.py index 2f8e197a36..e9e95ef1e7 100644 --- a/pcapkit/const/mh/cga_extension.py +++ b/pcapkit/const/mh/cga_extension.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -44,9 +44,9 @@ def _missing_(cls, value: 'int') -> 'CGAExtension': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0000 <= value <= 0x0011: #: Unassigned - return extend_enum(cls, 'Unassigned_%04x' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 0x0013 <= value <= 0xFFFC: #: Unassigned - return extend_enum(cls, 'Unassigned_%04x' % value, value) + return cls._unregistered_member(value, 'Unassigned') #: Unspecified in the IANA registry - return extend_enum(cls, 'Unassigned_%04x' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/cga_sec.py b/pcapkit/const/mh/cga_sec.py index edd3c5ce2e..ea08f79957 100644 --- a/pcapkit/const/mh/cga_sec.py +++ b/pcapkit/const/mh/cga_sec.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -40,4 +40,4 @@ def _missing_(cls, value: 'int') -> 'CGASec': if not (isinstance(value, int) and 0 <= value <= 0b111): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) #: Unspecified in the IANA registry - return extend_enum(cls, 'Unassigned_%s' % bin(value)[2:], value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/dhcp_support_mode.py b/pcapkit/const/mh/dhcp_support_mode.py index eb0301edf5..d76fdd411f 100644 --- a/pcapkit/const/mh/dhcp_support_mode.py +++ b/pcapkit/const/mh/dhcp_support_mode.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -36,4 +36,4 @@ def _missing_(cls, value: 'int') -> 'DHCPSupportMode': """ if not (isinstance(value, int) and 0 <= value <= 1): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/dns_status_code.py b/pcapkit/const/mh/dns_status_code.py index 5b708a079c..c68779019d 100644 --- a/pcapkit/const/mh/dns_status_code.py +++ b/pcapkit/const/mh/dns_status_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -44,8 +44,8 @@ def _missing_(cls, value: 'int') -> 'DNSStatusCode': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 131 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/dsmip6_tls_packet.py b/pcapkit/const/mh/dsmip6_tls_packet.py index 28ff3f2209..85cde08ab8 100644 --- a/pcapkit/const/mh/dsmip6_tls_packet.py +++ b/pcapkit/const/mh/dsmip6_tls_packet.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,8 +41,8 @@ def _missing_(cls, value: 'int') -> 'DSMIP6TLSPacket': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 2 <= value <= 7: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 9 <= value <= 15: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/dsmipv6_home_address.py b/pcapkit/const/mh/dsmipv6_home_address.py index 1c4fd0161a..16a490dd3c 100644 --- a/pcapkit/const/mh/dsmipv6_home_address.py +++ b/pcapkit/const/mh/dsmipv6_home_address.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -53,8 +53,8 @@ def _missing_(cls, value: 'int') -> 'DSMIPv6HomeAddress': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 134 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/enumerating_algorithm.py b/pcapkit/const/mh/enumerating_algorithm.py index 1d8071ee39..0f6c815c67 100644 --- a/pcapkit/const/mh/enumerating_algorithm.py +++ b/pcapkit/const/mh/enumerating_algorithm.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -39,4 +39,4 @@ def _missing_(cls, value: 'int') -> 'EnumeratingAlgorithm': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/fb_ack_status.py b/pcapkit/const/mh/fb_ack_status.py index 2b15d706e4..2fc317e34c 100644 --- a/pcapkit/const/mh/fb_ack_status.py +++ b/pcapkit/const/mh/fb_ack_status.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,8 +41,8 @@ def _missing_(cls, value: 'int') -> 'FlowBindingACKStatus': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 130 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/fb_action.py b/pcapkit/const/mh/fb_action.py index 9256f93693..0fd35f936c 100644 --- a/pcapkit/const/mh/fb_action.py +++ b/pcapkit/const/mh/fb_action.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -50,8 +50,8 @@ def _missing_(cls, value: 'int') -> 'FlowBindingAction': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0 <= value <= 10: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 17 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/fb_indication_trigger.py b/pcapkit/const/mh/fb_indication_trigger.py index 09d4a98205..51d7134f06 100644 --- a/pcapkit/const/mh/fb_indication_trigger.py +++ b/pcapkit/const/mh/fb_indication_trigger.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -44,8 +44,8 @@ def _missing_(cls, value: 'int') -> 'FlowBindingIndicationTrigger': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 4 <= value <= 249: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 250 <= value <= 255: #: Reserved for Testing Purposes Only [:rfc:`7109`] - return extend_enum(cls, 'Reserved_for_Testing_Purposes_Only_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Testing_Purposes_Only') return super()._missing_(value) diff --git a/pcapkit/const/mh/fb_type.py b/pcapkit/const/mh/fb_type.py index 4b4abef473..a016e6a733 100644 --- a/pcapkit/const/mh/fb_type.py +++ b/pcapkit/const/mh/fb_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,5 +41,5 @@ def _missing_(cls, value: 'int') -> 'FlowBindingType': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 3 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/flow_id_status.py b/pcapkit/const/mh/flow_id_status.py index 8825f986c6..e9b5b89b6b 100644 --- a/pcapkit/const/mh/flow_id_status.py +++ b/pcapkit/const/mh/flow_id_status.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -53,11 +53,11 @@ def _missing_(cls, value: 'int') -> 'FlowIDStatus': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned; available for success codes - return extend_enum(cls, 'Unassigned_available_for_success_codes_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned_available_for_success_codes') if 134 <= value <= 250: #: Unassigned; available for reject codes - return extend_enum(cls, 'Unassigned_available_for_reject_codes_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned_available_for_reject_codes') if 251 <= value <= 255: #: Reserved for Experimental Use [:rfc:`6089`] - return extend_enum(cls, 'Reserved_for_Experimental_Use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Experimental_Use') return super()._missing_(value) diff --git a/pcapkit/const/mh/flow_id_suboption.py b/pcapkit/const/mh/flow_id_suboption.py index ed6eb62210..f0c6ca09e1 100644 --- a/pcapkit/const/mh/flow_id_suboption.py +++ b/pcapkit/const/mh/flow_id_suboption.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -50,8 +50,8 @@ def _missing_(cls, value: 'int') -> 'FlowIDSuboption': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 6 <= value <= 250: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 251 <= value <= 255: #: Reserved for Experimental Use [:rfc:`6089`] - return extend_enum(cls, 'Reserved_for_Experimental_Use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Experimental_Use') return super()._missing_(value) diff --git a/pcapkit/const/mh/handoff_type.py b/pcapkit/const/mh/handoff_type.py index 43bbcbdf28..bf6036f84e 100644 --- a/pcapkit/const/mh/handoff_type.py +++ b/pcapkit/const/mh/handoff_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -53,5 +53,5 @@ def _missing_(cls, value: 'int') -> 'HandoffType': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 7 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/handover_ack_status.py b/pcapkit/const/mh/handover_ack_status.py index f5d7e53c25..ab75f40bac 100644 --- a/pcapkit/const/mh/handover_ack_status.py +++ b/pcapkit/const/mh/handover_ack_status.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -71,8 +71,8 @@ def _missing_(cls, value: 'int') -> 'HandoverACKStatus': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 7 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 133 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/handover_initiate_status.py b/pcapkit/const/mh/handover_initiate_status.py index 0f25bc5c7c..3c0a305f82 100644 --- a/pcapkit/const/mh/handover_initiate_status.py +++ b/pcapkit/const/mh/handover_initiate_status.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -44,5 +44,5 @@ def _missing_(cls, value: 'int') -> 'HandoverInitiateStatus': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 4 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/home_address_reply.py b/pcapkit/const/mh/home_address_reply.py index 265e09e4fa..189c420aad 100644 --- a/pcapkit/const/mh/home_address_reply.py +++ b/pcapkit/const/mh/home_address_reply.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -50,8 +50,8 @@ def _missing_(cls, value: 'int') -> 'HomeAddressReply': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 133 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/lla_code.py b/pcapkit/const/mh/lla_code.py index 8abdc81a9b..f74b67822e 100644 --- a/pcapkit/const/mh/lla_code.py +++ b/pcapkit/const/mh/lla_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -46,4 +46,4 @@ def _missing_(cls, value: 'int') -> 'LLACode': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/lma_mag_suboption.py b/pcapkit/const/mh/lma_mag_suboption.py index 2988c39b26..4f171e86a3 100644 --- a/pcapkit/const/mh/lma_mag_suboption.py +++ b/pcapkit/const/mh/lma_mag_suboption.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,5 +41,5 @@ def _missing_(cls, value: 'int') -> 'LMAControlledMAGSuboption': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 3 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/mn_group_id.py b/pcapkit/const/mh/mn_group_id.py index 724ac00b53..c05c34880c 100644 --- a/pcapkit/const/mh/mn_group_id.py +++ b/pcapkit/const/mh/mn_group_id.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,5 +41,5 @@ def _missing_(cls, value: 'int') -> 'MNGroupID': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 2 <= value <= 254: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/mn_id_subtype.py b/pcapkit/const/mh/mn_id_subtype.py index 36507e5959..345436c703 100644 --- a/pcapkit/const/mh/mn_id_subtype.py +++ b/pcapkit/const/mh/mn_id_subtype.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -56,8 +56,8 @@ def _missing_(cls, value: 'int') -> 'MNIDSubtype': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 9 <= value <= 15: #: Reserved [:rfc:`8371`] - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') if 16 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/operator_id.py b/pcapkit/const/mh/operator_id.py index afa9213720..9c2c906a56 100644 --- a/pcapkit/const/mh/operator_id.py +++ b/pcapkit/const/mh/operator_id.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -45,5 +45,5 @@ def _missing_(cls, value: 'int') -> 'OperatorID': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 3 <= value <= 254: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/option.py b/pcapkit/const/mh/option.py index c8e2a9c133..e9d529f65c 100644 --- a/pcapkit/const/mh/option.py +++ b/pcapkit/const/mh/option.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -243,4 +243,4 @@ def _missing_(cls, value: 'int') -> 'Option': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/packet.py b/pcapkit/const/mh/packet.py index 33774b00db..bfe7db38ea 100644 --- a/pcapkit/const/mh/packet.py +++ b/pcapkit/const/mh/packet.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -102,4 +102,4 @@ def _missing_(cls, value: 'int') -> 'Packet': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/qos_attribute.py b/pcapkit/const/mh/qos_attribute.py index 13ed521a8d..2d9ca0938d 100644 --- a/pcapkit/const/mh/qos_attribute.py +++ b/pcapkit/const/mh/qos_attribute.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -71,5 +71,5 @@ def _missing_(cls, value: 'int') -> 'QoSAttribute': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 12 <= value <= 254: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/revocation_status_code.py b/pcapkit/const/mh/revocation_status_code.py index 9d42d31fe6..3e8734b53e 100644 --- a/pcapkit/const/mh/revocation_status_code.py +++ b/pcapkit/const/mh/revocation_status_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -62,8 +62,8 @@ def _missing_(cls, value: 'int') -> 'RevocationStatusCode': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 2 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 136 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/revocation_trigger.py b/pcapkit/const/mh/revocation_trigger.py index 71fab858d8..09c6beb892 100644 --- a/pcapkit/const/mh/revocation_trigger.py +++ b/pcapkit/const/mh/revocation_trigger.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -62,11 +62,11 @@ def _missing_(cls, value: 'int') -> 'RevocationTrigger': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 8 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 130 <= value <= 249: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 250 <= value <= 255: #: Reserved for Testing Purposes Only [:rfc:`5846`] - return extend_enum(cls, 'Reserved_for_Testing_Purposes_Only_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Testing_Purposes_Only') return super()._missing_(value) diff --git a/pcapkit/const/mh/status_code.py b/pcapkit/const/mh/status_code.py index 560df024b6..55b8ae43ae 100644 --- a/pcapkit/const/mh/status_code.py +++ b/pcapkit/const/mh/status_code.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -213,6 +213,6 @@ def _missing_(cls, value: 'int') -> 'StatusCode': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 7 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') #: Unspecified in the IANA registry - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/mh/traffic_selector.py b/pcapkit/const/mh/traffic_selector.py index b44353ddb3..01a07e996d 100644 --- a/pcapkit/const/mh/traffic_selector.py +++ b/pcapkit/const/mh/traffic_selector.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -41,8 +41,8 @@ def _missing_(cls, value: 'int') -> 'TrafficSelector': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 3 <= value <= 250: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 251 <= value <= 255: #: Reserved for Experimental Use [:rfc:`6089`] - return extend_enum(cls, 'Reserved_for_Experimental_Use_%d' % value, value) + return cls._unregistered_member(value, 'Reserved_for_Experimental_Use') return super()._missing_(value) diff --git a/pcapkit/const/mh/upa_status.py b/pcapkit/const/mh/upa_status.py index fec56e0f80..ec982bfaea 100644 --- a/pcapkit/const/mh/upa_status.py +++ b/pcapkit/const/mh/upa_status.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -50,8 +50,8 @@ def _missing_(cls, value: 'int') -> 'UpdateNotificationACKStatus': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 1 <= value <= 127: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') if 133 <= value <= 255: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/mh/upn_reason.py b/pcapkit/const/mh/upn_reason.py index b53c2acaef..aa508989b8 100644 --- a/pcapkit/const/mh/upn_reason.py +++ b/pcapkit/const/mh/upn_reason.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -62,5 +62,5 @@ def _missing_(cls, value: 'int') -> 'UpdateNotificationReason': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 9 <= value <= 254: #: Unassigned - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/pcapng/block_type.py b/pcapkit/const/pcapng/block_type.py index f922f70547..f29582d982 100644 --- a/pcapkit/const/pcapng/block_type.py +++ b/pcapkit/const/pcapng/block_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -122,17 +122,17 @@ def _missing_(cls, value: 'int') -> 'BlockType': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0a0d0a00 <= value <= 0x0a0d0aff: #: Reserved. Used to detect trace files corrupted because of file transfers using the HTTP protocol in text mode. - return extend_enum(cls, 'Reserved_%08x' % value, value) + return cls._unregistered_member(value, 'Reserved') if 0x000a0d0a <= value <= 0xff0a0d0a: #: Reserved. Used to detect trace files corrupted because of file transfers using the HTTP protocol in text mode. - return extend_enum(cls, 'Reserved_%08x' % value, value) + return cls._unregistered_member(value, 'Reserved') if 0x000a0d0d <= value <= 0xff0a0d0d: #: Reserved. Used to detect trace files corrupted because of file transfers using the HTTP protocol in text mode. - return extend_enum(cls, 'Reserved_%08x' % value, value) + return cls._unregistered_member(value, 'Reserved') if 0x0d0d0a00 <= value <= 0x0d0d0aff: #: Reserved. Used to detect trace files corrupted because of file transfers using the FTP protocol in text mode. - return extend_enum(cls, 'Reserved_%08x' % value, value) + return cls._unregistered_member(value, 'Reserved') if 0x80000000 <= value <= 0xffffffff: #: Reserved for local use. - return extend_enum(cls, 'Reserved_%08x' % value, value) + return cls._unregistered_member(value, 'Reserved') return super()._missing_(value) diff --git a/pcapkit/const/pcapng/filter_type.py b/pcapkit/const/pcapng/filter_type.py index 9fc0fe9872..d004ad8d8b 100644 --- a/pcapkit/const/pcapng/filter_type.py +++ b/pcapkit/const/pcapng/filter_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -31,4 +31,4 @@ def _missing_(cls, value: 'int') -> 'FilterType': """ if not (isinstance(value, int) and 0x00<= value <= 0xFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/pcapng/hash_algorithm.py b/pcapkit/const/pcapng/hash_algorithm.py index 670152ac9b..637039e0aa 100644 --- a/pcapkit/const/pcapng/hash_algorithm.py +++ b/pcapkit/const/pcapng/hash_algorithm.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -42,4 +42,4 @@ def _missing_(cls, value: 'int') -> 'HashAlgorithm': """ if not (isinstance(value, int) and 0x00 <= value <= 0xFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/pcapng/record_type.py b/pcapkit/const/pcapng/record_type.py index ab055cebaf..44bda661cd 100644 --- a/pcapkit/const/pcapng/record_type.py +++ b/pcapkit/const/pcapng/record_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -39,5 +39,5 @@ def _missing_(cls, value: 'int') -> 'RecordType': """ if not (isinstance(value, int) and 0 <= value <= 0xFFFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - extend_enum(cls, 'Unassigned_0x%04x' % value, value) + return cls._unregistered_member(value, 'Unassigned') return cls(value) diff --git a/pcapkit/const/pcapng/secrets_type.py b/pcapkit/const/pcapng/secrets_type.py index c9cb64248b..cce03e0da3 100644 --- a/pcapkit/const/pcapng/secrets_type.py +++ b/pcapkit/const/pcapng/secrets_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,5 +38,5 @@ def _missing_(cls, value: 'int') -> 'SecretsType': """ if not (isinstance(value, int) and 0x00000000 <= value <= 0xFFFFFFFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - extend_enum(cls, 'Unassigned_0x%08x' % value, value) + return cls._unregistered_member(value, 'Unassigned') return cls(value) diff --git a/pcapkit/const/pcapng/verdict_type.py b/pcapkit/const/pcapng/verdict_type.py index 86b4578336..7dd997bbd4 100644 --- a/pcapkit/const/pcapng/verdict_type.py +++ b/pcapkit/const/pcapng/verdict_type.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -36,4 +36,4 @@ def _missing_(cls, value: 'int') -> 'VerdictType': """ if not (isinstance(value, int) and 0x00 <= value <= 0xFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/reg/ethertype.py b/pcapkit/const/reg/ethertype.py index 1e81d4e706..73bca487e8 100644 --- a/pcapkit/const/reg/ethertype.py +++ b/pcapkit/const/reg/ethertype.py @@ -534,7 +534,7 @@ def _missing_(cls, value: 'int') -> 'EtherType': if 0x0101 <= value <= 0x01FF: #: Old Xerox Experimental values. Invalid as an Ethertype since 1983. [Neil #: Sembower] - return extend_enum(cls, 'Old_Xerox_Experimental_values_Invalid_as_an_Ethertype_since_1983_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'Old_Xerox_Experimental_values_Invalid_as_an_Ethertype_since_1983') if 0x0888 <= value <= 0x088A: #: Xyplex [Neil Sembower] return extend_enum(cls, 'Xyplex_0x%s' % hex(value)[2:].upper().zfill(4), value) @@ -543,7 +543,7 @@ def _missing_(cls, value: 'int') -> 'EtherType': return extend_enum(cls, 'Berkeley_Trailer_encap_IP_0x%s' % hex(value)[2:].upper().zfill(4), value) if 0x6008 <= value <= 0x6009: #: DEC Unassigned [Neil Sembower] - return extend_enum(cls, 'DEC_Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'DEC_Unassigned') if 0x6010 <= value <= 0x6014: #: 3Com Corporation [Neil Sembower] return extend_enum(cls, 'EtherType_3Com_Corporation_0x%s' % hex(value)[2:].upper().zfill(4), value) @@ -552,10 +552,10 @@ def _missing_(cls, value: 'int') -> 'EtherType': return extend_enum(cls, 'LRT_0x%s' % hex(value)[2:].upper().zfill(4), value) if 0x8039 <= value <= 0x803C: #: DEC Unassigned [Neil Sembower] - return extend_enum(cls, 'DEC_Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'DEC_Unassigned') if 0x8040 <= value <= 0x8042: #: DEC Unassigned [Neil Sembower] - return extend_enum(cls, 'DEC_Unassigned_0x%s' % hex(value)[2:].upper().zfill(4), value) + return cls._unregistered_member(value, 'DEC_Unassigned') if 0x806E <= value <= 0x8077: #: Landmark Graphics Corp. [Neil Sembower] return extend_enum(cls, 'Landmark_Graphics_Corp_0x%s' % hex(value)[2:].upper().zfill(4), value) diff --git a/pcapkit/const/reg/linktype.py b/pcapkit/const/reg/linktype.py index 833460bf4c..1274f8b662 100644 --- a/pcapkit/const/reg/linktype.py +++ b/pcapkit/const/reg/linktype.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -762,4 +762,4 @@ def _missing_(cls, value: 'int') -> 'LinkType': """ if not (isinstance(value, int) and 0x00000000 <= value <= 0xFFFFFFFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/reg/transtype.py b/pcapkit/const/reg/transtype.py index bf1bacd9ca..cd6a700c9d 100644 --- a/pcapkit/const/reg/transtype.py +++ b/pcapkit/const/reg/transtype.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -508,5 +508,5 @@ def _missing_(cls, value: 'int') -> 'TransType': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 148 <= value <= 252: #: Unassigned [Internet Assigned Numbers Authority] - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/tcp/checksum.py b/pcapkit/const/tcp/checksum.py index 9050fdbd62..043c3ec5e1 100644 --- a/pcapkit/const/tcp/checksum.py +++ b/pcapkit/const/tcp/checksum.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -38,4 +38,4 @@ def _missing_(cls, value: 'int') -> 'Checksum': """ if not (isinstance(value, int) and 0 <= value <= 255): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/const/tcp/mp_tcp_option.py b/pcapkit/const/tcp/mp_tcp_option.py index 038a5364d3..d988677854 100644 --- a/pcapkit/const/tcp/mp_tcp_option.py +++ b/pcapkit/const/tcp/mp_tcp_option.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -62,5 +62,5 @@ def _missing_(cls, value: 'int') -> 'MPTCPOption': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x9 <= value <= 0xe: #: - return extend_enum(cls, 'Unassigned_%d' % value, value) + return cls._unregistered_member(value, 'Unassigned') return super()._missing_(value) diff --git a/pcapkit/const/tcp/option.py b/pcapkit/const/tcp/option.py index 3c76b1fa7d..380eebdc95 100644 --- a/pcapkit/const/tcp/option.py +++ b/pcapkit/const/tcp/option.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -169,14 +169,14 @@ def _missing_(cls, value: 'int') -> 'Option': raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 35 <= value <= 68: #: Reserved - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') if 71 <= value <= 75: #: Reserved - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') if 79 <= value <= 171: #: Reserved - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') if 175 <= value <= 252: #: Reserved - return extend_enum(cls, 'Reserved_%d' % value, value) + return cls._unregistered_member(value, 'Reserved') return super()._missing_(value) diff --git a/pcapkit/const/vlan/priority_level.py b/pcapkit/const/vlan/priority_level.py index 3e151c41f4..ac2038b770 100644 --- a/pcapkit/const/vlan/priority_level.py +++ b/pcapkit/const/vlan/priority_level.py @@ -10,7 +10,7 @@ """ -from aenum import IntEnum, extend_enum +from aenum import IntEnum from pcapkit.corekit.enum import EnumRegistry @@ -54,4 +54,4 @@ def _missing_(cls, value: 'int') -> 'PriorityLevel': """ if not (isinstance(value, int) and 0b000 <= value <= 0b111): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - return extend_enum(cls, 'Unassigned [0b%s]' % bin(value)[2:].zfill(3), value) + return cls._unregistered_member(value, 'Unassigned') diff --git a/pcapkit/vendor/esp/cipher.py b/pcapkit/vendor/esp/cipher.py index aed7aa7d18..2fdff763ca 100644 --- a/pcapkit/vendor/esp/cipher.py +++ b/pcapkit/vendor/esp/cipher.py @@ -85,7 +85,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") continue renm = self.rename(name, code) diff --git a/pcapkit/vendor/esp/integrity.py b/pcapkit/vendor/esp/integrity.py index 15bd6e52cd..37aa278e8f 100644 --- a/pcapkit/vendor/esp/integrity.py +++ b/pcapkit/vendor/esp/integrity.py @@ -83,7 +83,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") continue renm = self.rename(name, code) diff --git a/pcapkit/vendor/hip/eddsa_curve.py b/pcapkit/vendor/hip/eddsa_curve.py index 505132ec12..ca70cb7d9c 100644 --- a/pcapkit/vendor/hip/eddsa_curve.py +++ b/pcapkit/vendor/hip/eddsa_curve.py @@ -77,7 +77,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/hip/group.py b/pcapkit/vendor/hip/group.py index 5fe097056a..a97d11db5d 100644 --- a/pcapkit/vendor/hip/group.py +++ b/pcapkit/vendor/hip/group.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' # {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/hip/packet.py b/pcapkit/vendor/hip/packet.py index 9fb97e0f9e..885680c8d9 100644 --- a/pcapkit/vendor/hip/packet.py +++ b/pcapkit/vendor/hip/packet.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' # {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/hip/parameter.py b/pcapkit/vendor/hip/parameter.py index fabce7b4d6..237ea3d505 100644 --- a/pcapkit/vendor/hip/parameter.py +++ b/pcapkit/vendor/hip/parameter.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f" #: {desc}") - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/http/error_code.py b/pcapkit/vendor/http/error_code.py index ca6aa9aaed..75cf190a20 100644 --- a/pcapkit/vendor/http/error_code.py +++ b/pcapkit/vendor/http/error_code.py @@ -86,8 +86,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {hexlify(start)} <= value <= {hexlify(stop)}:') miss.append(f' #: {desc}') - miss.append(f' temp = hex(value)[2:].upper().zfill(8)') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_0x%s' % (temp[:4]+'_'+temp[4:]), value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/http/frame.py b/pcapkit/vendor/http/frame.py index 16353fd594..d54947c917 100644 --- a/pcapkit/vendor/http/frame.py +++ b/pcapkit/vendor/http/frame.py @@ -83,7 +83,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {hexlify(start)} <= value <= {hexlify(stop)}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_0x%s' % hex(value)[2:].upper().zfill(2), value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/http/setting.py b/pcapkit/vendor/http/setting.py index 942aa384e1..9ca2f7062b 100644 --- a/pcapkit/vendor/http/setting.py +++ b/pcapkit/vendor/http/setting.py @@ -85,7 +85,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {hexlify(start)} <= value <= {hexlify(stop)}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_0x%s' % hex(value)[2:].upper().zfill(4), value)") # pylint: disable=line-too-long + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") # pylint: disable=line-too-long return enum, miss diff --git a/pcapkit/vendor/ipv4/classification_level.py b/pcapkit/vendor/ipv4/classification_level.py index 53190410e5..8b60a0d071 100644 --- a/pcapkit/vendor/ipv4/classification_level.py +++ b/pcapkit/vendor/ipv4/classification_level.py @@ -77,8 +77,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - 'temp = bin(value)[2:].upper().zfill(8)', - "return extend_enum(cls, 'Unassigned_0b%s' % (temp[:4]+'_'+temp[4:]), value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): bncd = binary(code) diff --git a/pcapkit/vendor/ipv4/option_class.py b/pcapkit/vendor/ipv4/option_class.py index 12d656350e..ed504113eb 100644 --- a/pcapkit/vendor/ipv4/option_class.py +++ b/pcapkit/vendor/ipv4/option_class.py @@ -68,7 +68,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/option_number.py b/pcapkit/vendor/ipv4/option_number.py index 0f330f01c7..8a483cdffe 100644 --- a/pcapkit/vendor/ipv4/option_number.py +++ b/pcapkit/vendor/ipv4/option_number.py @@ -61,7 +61,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: code = item[3] diff --git a/pcapkit/vendor/ipv4/protection_authority.py b/pcapkit/vendor/ipv4/protection_authority.py index 686523d96b..83a4cfa5bc 100644 --- a/pcapkit/vendor/ipv4/protection_authority.py +++ b/pcapkit/vendor/ipv4/protection_authority.py @@ -72,7 +72,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/qs_function.py b/pcapkit/vendor/ipv4/qs_function.py index bab89573b6..ea199cfa52 100644 --- a/pcapkit/vendor/ipv4/qs_function.py +++ b/pcapkit/vendor/ipv4/qs_function.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/router_alert.py b/pcapkit/vendor/ipv4/router_alert.py index 4558755d58..d04a072d43 100644 --- a/pcapkit/vendor/ipv4/router_alert.py +++ b/pcapkit/vendor/ipv4/router_alert.py @@ -88,7 +88,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': else: miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/ipv4/tos_del.py b/pcapkit/vendor/ipv4/tos_del.py index 27b66b9190..8c5a27460c 100644 --- a/pcapkit/vendor/ipv4/tos_del.py +++ b/pcapkit/vendor/ipv4/tos_del.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code).upper() # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/tos_ecn.py b/pcapkit/vendor/ipv4/tos_ecn.py index 9368c4609c..3be47d7d66 100644 --- a/pcapkit/vendor/ipv4/tos_ecn.py +++ b/pcapkit/vendor/ipv4/tos_ecn.py @@ -83,7 +83,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_0b%s' % bin(value)[2:].zfill(2), value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) diff --git a/pcapkit/vendor/ipv4/tos_pre.py b/pcapkit/vendor/ipv4/tos_pre.py index 729d593798..1d64ff8d8b 100644 --- a/pcapkit/vendor/ipv4/tos_pre.py +++ b/pcapkit/vendor/ipv4/tos_pre.py @@ -72,7 +72,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/tos_rel.py b/pcapkit/vendor/ipv4/tos_rel.py index 6f62c7d9bf..62021f179e 100644 --- a/pcapkit/vendor/ipv4/tos_rel.py +++ b/pcapkit/vendor/ipv4/tos_rel.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code).upper() # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/tos_thr.py b/pcapkit/vendor/ipv4/tos_thr.py index aa5ddc5c1f..3745cd571b 100644 --- a/pcapkit/vendor/ipv4/tos_thr.py +++ b/pcapkit/vendor/ipv4/tos_thr.py @@ -65,7 +65,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code).upper() # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv4/ts_flag.py b/pcapkit/vendor/ipv4/ts_flag.py index 00bb8c1c86..126a90d423 100644 --- a/pcapkit/vendor/ipv4/ts_flag.py +++ b/pcapkit/vendor/ipv4/ts_flag.py @@ -67,7 +67,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv6/option.py b/pcapkit/vendor/ipv6/option.py index 00a528406f..cecdd7fa95 100644 --- a/pcapkit/vendor/ipv6/option.py +++ b/pcapkit/vendor/ipv6/option.py @@ -60,7 +60,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_0x%s' % hex(value)[2:].upper().zfill(2), value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: if not item[0]: diff --git a/pcapkit/vendor/ipv6/option_action.py b/pcapkit/vendor/ipv6/option_action.py index 953ec0b884..7d22c01ae5 100644 --- a/pcapkit/vendor/ipv6/option_action.py +++ b/pcapkit/vendor/ipv6/option_action.py @@ -78,7 +78,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv6/qs_function.py b/pcapkit/vendor/ipv6/qs_function.py index be40f57593..4a46284333 100644 --- a/pcapkit/vendor/ipv6/qs_function.py +++ b/pcapkit/vendor/ipv6/qs_function.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv6/router_alert.py b/pcapkit/vendor/ipv6/router_alert.py index 6b6670ac67..cdefb522b1 100644 --- a/pcapkit/vendor/ipv6/router_alert.py +++ b/pcapkit/vendor/ipv6/router_alert.py @@ -85,7 +85,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': else: miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/ipv6/routing.py b/pcapkit/vendor/ipv6/routing.py index 65f57f36dc..aa5351c731 100644 --- a/pcapkit/vendor/ipv6/routing.py +++ b/pcapkit/vendor/ipv6/routing.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/ipv6/seed_id.py b/pcapkit/vendor/ipv6/seed_id.py index e933f52529..f6eed55bab 100644 --- a/pcapkit/vendor/ipv6/seed_id.py +++ b/pcapkit/vendor/ipv6/seed_id.py @@ -68,7 +68,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_0b%s' % bin(value)[2:].zfill(2), value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): bncd = f'0b{bin(code)[2:].zfill(2)}' diff --git a/pcapkit/vendor/ipv6/smf_dpd_mode.py b/pcapkit/vendor/ipv6/smf_dpd_mode.py index 9552143ee4..f529826b84 100644 --- a/pcapkit/vendor/ipv6/smf_dpd_mode.py +++ b/pcapkit/vendor/ipv6/smf_dpd_mode.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/ipv6/tagger_id.py b/pcapkit/vendor/ipv6/tagger_id.py index a5a223aa45..a8ab6c1a17 100644 --- a/pcapkit/vendor/ipv6/tagger_id.py +++ b/pcapkit/vendor/ipv6/tagger_id.py @@ -73,7 +73,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/ipx/packet.py b/pcapkit/vendor/ipx/packet.py index 7a1f0c1361..059f9734cc 100644 --- a/pcapkit/vendor/ipx/packet.py +++ b/pcapkit/vendor/ipx/packet.py @@ -189,7 +189,7 @@ def process(self, data: 'dict[int, tuple[str, str]]') -> 'tuple[list[str], list[ """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, (name, desc) in data.items(): diff --git a/pcapkit/vendor/ipx/socket.py b/pcapkit/vendor/ipx/socket.py index 1820bb2e60..88ce357404 100644 --- a/pcapkit/vendor/ipx/socket.py +++ b/pcapkit/vendor/ipx/socket.py @@ -250,6 +250,18 @@ (0x0BB9, 0xFFFF, 'Dynamically Assigned'), ] # type: list[tuple[int, int, str]] +#: Range names from :data:`RANGES` above that name an allocation *policy* for +#: the pool (who may claim a code, or that nobody has) rather than a specific +#: assigned protocol -- the owner's ruling on #775/#847. ``Registered by +#: Xerox`` stays a mint: it is a real ownership fact, not a placeholder, and +#: kept notation for the reader is what only these four are. +UNASSIGNED_RANGE_NAMES = frozenset({ + 'Experimental', + 'Dynamically Assigned Socket Numbers', + 'Statically Assigned Socket Numbers', + 'Dynamically Assigned', +}) + class Socket(Vendor): """Socket Types""" @@ -304,7 +316,10 @@ def process(self, data: 'dict[int, tuple[str, str]]') -> 'tuple[list[str], list[ for start, stop, name in RANGES: miss.append(f'if 0x{start:04X} <= value <= 0x{stop:04X}:') miss.append(f' #: {self.wrap_comment(name)}') - miss.append(f" return extend_enum(cls, '{name}_0x%s' % hex(value)[2:].upper().zfill(4), value)") + if name in UNASSIGNED_RANGE_NAMES: + miss.append(f" return cls._unregistered_member(value, '{name}')") + else: + miss.append(f" return extend_enum(cls, '{name}_0x%s' % hex(value)[2:].upper().zfill(4), value)") return enum, miss diff --git a/pcapkit/vendor/l2tp/type.py b/pcapkit/vendor/l2tp/type.py index 455af326e9..0d4dda6e34 100644 --- a/pcapkit/vendor/l2tp/type.py +++ b/pcapkit/vendor/l2tp/type.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = list() miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/mh/access_type.py b/pcapkit/vendor/mh/access_type.py index d6ff965559..3069d41891 100644 --- a/pcapkit/vendor/mh/access_type.py +++ b/pcapkit/vendor/mh/access_type.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/ack_status_code.py b/pcapkit/vendor/mh/ack_status_code.py index b7fca6c8ca..758298afdb 100644 --- a/pcapkit/vendor/mh/ack_status_code.py +++ b/pcapkit/vendor/mh/ack_status_code.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/ani_suboption.py b/pcapkit/vendor/mh/ani_suboption.py index 1e2886caea..4c86df6baa 100644 --- a/pcapkit/vendor/mh/ani_suboption.py +++ b/pcapkit/vendor/mh/ani_suboption.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/auth_subtype.py b/pcapkit/vendor/mh/auth_subtype.py index 8b60181843..1448f87f4a 100644 --- a/pcapkit/vendor/mh/auth_subtype.py +++ b/pcapkit/vendor/mh/auth_subtype.py @@ -41,7 +41,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: long = item[1] diff --git a/pcapkit/vendor/mh/binding_error.py b/pcapkit/vendor/mh/binding_error.py index c5b5f49edb..9cfd309f92 100644 --- a/pcapkit/vendor/mh/binding_error.py +++ b/pcapkit/vendor/mh/binding_error.py @@ -66,7 +66,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/mh/binding_revocation.py b/pcapkit/vendor/mh/binding_revocation.py index 087736ff69..ca790bc0b0 100644 --- a/pcapkit/vendor/mh/binding_revocation.py +++ b/pcapkit/vendor/mh/binding_revocation.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/cga_extension.py b/pcapkit/vendor/mh/cga_extension.py index b42e158911..c778e50a1a 100644 --- a/pcapkit/vendor/mh/cga_extension.py +++ b/pcapkit/vendor/mh/cga_extension.py @@ -79,11 +79,11 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%04x' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") # TODO: figure out how to handle this programmatically miss.append('#: Unspecified in the IANA registry') - miss.append("return extend_enum(cls, 'Unassigned_%04x' % value, value)") + miss.append("return cls._unregistered_member(value, 'Unassigned')") return enum, miss diff --git a/pcapkit/vendor/mh/cga_sec.py b/pcapkit/vendor/mh/cga_sec.py index bbaa197d23..88e0dfd68a 100644 --- a/pcapkit/vendor/mh/cga_sec.py +++ b/pcapkit/vendor/mh/cga_sec.py @@ -79,11 +79,11 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%s' % bin(value)[2:], value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") # TODO: figure out how to handle this programmatically miss.append('#: Unspecified in the IANA registry') - miss.append("return extend_enum(cls, 'Unassigned_%s' % bin(value)[2:], value)") + miss.append("return cls._unregistered_member(value, 'Unassigned')") return enum, miss diff --git a/pcapkit/vendor/mh/dhcp_support_mode.py b/pcapkit/vendor/mh/dhcp_support_mode.py index 1e0b376ace..b4c5805a1f 100644 --- a/pcapkit/vendor/mh/dhcp_support_mode.py +++ b/pcapkit/vendor/mh/dhcp_support_mode.py @@ -41,7 +41,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: long = item[1] diff --git a/pcapkit/vendor/mh/dns_status_code.py b/pcapkit/vendor/mh/dns_status_code.py index cbfd1c8042..5e28edde55 100644 --- a/pcapkit/vendor/mh/dns_status_code.py +++ b/pcapkit/vendor/mh/dns_status_code.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/dsmip6_tls_packet.py b/pcapkit/vendor/mh/dsmip6_tls_packet.py index 7403973d1a..67733deb8c 100644 --- a/pcapkit/vendor/mh/dsmip6_tls_packet.py +++ b/pcapkit/vendor/mh/dsmip6_tls_packet.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/dsmipv6_home_address.py b/pcapkit/vendor/mh/dsmipv6_home_address.py index eb37116633..68bdb04e20 100644 --- a/pcapkit/vendor/mh/dsmipv6_home_address.py +++ b/pcapkit/vendor/mh/dsmipv6_home_address.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/enumerating_algorithm.py b/pcapkit/vendor/mh/enumerating_algorithm.py index 3bc776b20c..9c0ff0a6e6 100644 --- a/pcapkit/vendor/mh/enumerating_algorithm.py +++ b/pcapkit/vendor/mh/enumerating_algorithm.py @@ -41,7 +41,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: long = item[1] diff --git a/pcapkit/vendor/mh/fb_ack_status.py b/pcapkit/vendor/mh/fb_ack_status.py index 39ff980c07..9bbc418c00 100644 --- a/pcapkit/vendor/mh/fb_ack_status.py +++ b/pcapkit/vendor/mh/fb_ack_status.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/fb_action.py b/pcapkit/vendor/mh/fb_action.py index c0b8a90616..a3f2737d4f 100644 --- a/pcapkit/vendor/mh/fb_action.py +++ b/pcapkit/vendor/mh/fb_action.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/fb_indication_trigger.py b/pcapkit/vendor/mh/fb_indication_trigger.py index 74ca3cd26d..185f2753ea 100644 --- a/pcapkit/vendor/mh/fb_indication_trigger.py +++ b/pcapkit/vendor/mh/fb_indication_trigger.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/fb_type.py b/pcapkit/vendor/mh/fb_type.py index 55deadf86a..92d75c4be8 100644 --- a/pcapkit/vendor/mh/fb_type.py +++ b/pcapkit/vendor/mh/fb_type.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/flow_id_status.py b/pcapkit/vendor/mh/flow_id_status.py index 4766f9ce85..1a36d597f2 100644 --- a/pcapkit/vendor/mh/flow_id_status.py +++ b/pcapkit/vendor/mh/flow_id_status.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/flow_id_suboption.py b/pcapkit/vendor/mh/flow_id_suboption.py index 4605563b09..bb55c4e629 100644 --- a/pcapkit/vendor/mh/flow_id_suboption.py +++ b/pcapkit/vendor/mh/flow_id_suboption.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/handoff_type.py b/pcapkit/vendor/mh/handoff_type.py index 608875cfa1..36c126a8ed 100644 --- a/pcapkit/vendor/mh/handoff_type.py +++ b/pcapkit/vendor/mh/handoff_type.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/handover_ack_status.py b/pcapkit/vendor/mh/handover_ack_status.py index 79081fbb72..8e3562c3a2 100644 --- a/pcapkit/vendor/mh/handover_ack_status.py +++ b/pcapkit/vendor/mh/handover_ack_status.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/handover_initiate_status.py b/pcapkit/vendor/mh/handover_initiate_status.py index dc095c086a..7734a68746 100644 --- a/pcapkit/vendor/mh/handover_initiate_status.py +++ b/pcapkit/vendor/mh/handover_initiate_status.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/home_address_reply.py b/pcapkit/vendor/mh/home_address_reply.py index a4a96d9a3b..14e117ae73 100644 --- a/pcapkit/vendor/mh/home_address_reply.py +++ b/pcapkit/vendor/mh/home_address_reply.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/lla_code.py b/pcapkit/vendor/mh/lla_code.py index 8f8f878827..8d9d613216 100644 --- a/pcapkit/vendor/mh/lla_code.py +++ b/pcapkit/vendor/mh/lla_code.py @@ -85,7 +85,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/mh/lma_mag_suboption.py b/pcapkit/vendor/mh/lma_mag_suboption.py index fc14b30fce..65c0dd5ba4 100644 --- a/pcapkit/vendor/mh/lma_mag_suboption.py +++ b/pcapkit/vendor/mh/lma_mag_suboption.py @@ -80,7 +80,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/mn_group_id.py b/pcapkit/vendor/mh/mn_group_id.py index b3a40139d8..befaf4ea41 100644 --- a/pcapkit/vendor/mh/mn_group_id.py +++ b/pcapkit/vendor/mh/mn_group_id.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/mn_id_subtype.py b/pcapkit/vendor/mh/mn_id_subtype.py index bae72d4f52..62575fdde7 100644 --- a/pcapkit/vendor/mh/mn_id_subtype.py +++ b/pcapkit/vendor/mh/mn_id_subtype.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/operator_id.py b/pcapkit/vendor/mh/operator_id.py index dc30116ad4..3588fbd1a1 100644 --- a/pcapkit/vendor/mh/operator_id.py +++ b/pcapkit/vendor/mh/operator_id.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/option.py b/pcapkit/vendor/mh/option.py index b1c9adc12f..c98421c333 100644 --- a/pcapkit/vendor/mh/option.py +++ b/pcapkit/vendor/mh/option.py @@ -42,7 +42,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: long = item[1] diff --git a/pcapkit/vendor/mh/packet.py b/pcapkit/vendor/mh/packet.py index 56c397b6c4..a593f4cfd2 100644 --- a/pcapkit/vendor/mh/packet.py +++ b/pcapkit/vendor/mh/packet.py @@ -41,7 +41,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in reader: long = item[1] diff --git a/pcapkit/vendor/mh/qos_attribute.py b/pcapkit/vendor/mh/qos_attribute.py index 262c03e739..6107a52abc 100644 --- a/pcapkit/vendor/mh/qos_attribute.py +++ b/pcapkit/vendor/mh/qos_attribute.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/revocation_status_code.py b/pcapkit/vendor/mh/revocation_status_code.py index 514d5f05ed..d073d82ef8 100644 --- a/pcapkit/vendor/mh/revocation_status_code.py +++ b/pcapkit/vendor/mh/revocation_status_code.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/revocation_trigger.py b/pcapkit/vendor/mh/revocation_trigger.py index 76b48295cb..928ef5d03a 100644 --- a/pcapkit/vendor/mh/revocation_trigger.py +++ b/pcapkit/vendor/mh/revocation_trigger.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/status_code.py b/pcapkit/vendor/mh/status_code.py index 357560cf91..70b88f6340 100644 --- a/pcapkit/vendor/mh/status_code.py +++ b/pcapkit/vendor/mh/status_code.py @@ -79,11 +79,11 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") # TODO: figure out how to handle this programmatically miss.append('#: Unspecified in the IANA registry') - miss.append("return extend_enum(cls, 'Unassigned_%d' % value, value)") + miss.append("return cls._unregistered_member(value, 'Unassigned')") return enum, miss diff --git a/pcapkit/vendor/mh/traffic_selector.py b/pcapkit/vendor/mh/traffic_selector.py index af826c8583..2b2a54113b 100644 --- a/pcapkit/vendor/mh/traffic_selector.py +++ b/pcapkit/vendor/mh/traffic_selector.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/upa_status.py b/pcapkit/vendor/mh/upa_status.py index ac7cbd78b9..05db230402 100644 --- a/pcapkit/vendor/mh/upa_status.py +++ b/pcapkit/vendor/mh/upa_status.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/mh/upn_reason.py b/pcapkit/vendor/mh/upn_reason.py index 1b5678a3ec..65d0633f18 100644 --- a/pcapkit/vendor/mh/upn_reason.py +++ b/pcapkit/vendor/mh/upn_reason.py @@ -79,7 +79,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/pcapng/block_type.py b/pcapkit/vendor/pcapng/block_type.py index d125c58e2f..bb9009ab97 100644 --- a/pcapkit/vendor/pcapng/block_type.py +++ b/pcapkit/vendor/pcapng/block_type.py @@ -128,7 +128,7 @@ def process(self, data: 'list[Tag]') -> 'tuple[list[str], list[str]]': miss.append(f'if 0x{start:08x} <= value <= 0x{stop:08x}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_%08x' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") return enum, miss diff --git a/pcapkit/vendor/pcapng/filter_type.py b/pcapkit/vendor/pcapng/filter_type.py index 2be7b8829e..ad294da814 100644 --- a/pcapkit/vendor/pcapng/filter_type.py +++ b/pcapkit/vendor/pcapng/filter_type.py @@ -65,7 +65,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/pcapng/hash_algorithm.py b/pcapkit/vendor/pcapng/hash_algorithm.py index 76b9946203..5cb9131048 100644 --- a/pcapkit/vendor/pcapng/hash_algorithm.py +++ b/pcapkit/vendor/pcapng/hash_algorithm.py @@ -70,7 +70,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/pcapng/record_type.py b/pcapkit/vendor/pcapng/record_type.py index dae32c0dfd..bef958c954 100644 --- a/pcapkit/vendor/pcapng/record_type.py +++ b/pcapkit/vendor/pcapng/record_type.py @@ -64,7 +64,7 @@ def process(self, data: 'list[Tag]') -> 'tuple[list[str], list[str]]': """ enum = [] # type: list[str] miss = [ - "extend_enum(cls, 'Unassigned_0x%04x' % value, value)", + "cls._unregistered_member(value, 'Unassigned')", 'return cls(value)' ] for content in data: diff --git a/pcapkit/vendor/pcapng/secrets_type.py b/pcapkit/vendor/pcapng/secrets_type.py index bb5cc3d4c6..8b97fa43f7 100644 --- a/pcapkit/vendor/pcapng/secrets_type.py +++ b/pcapkit/vendor/pcapng/secrets_type.py @@ -68,7 +68,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "extend_enum(cls, 'Unassigned_0x%08x' % value, value)", + "cls._unregistered_member(value, 'Unassigned')", 'return cls(value)' ] for code, name in DATA.items(): diff --git a/pcapkit/vendor/pcapng/verdict_type.py b/pcapkit/vendor/pcapng/verdict_type.py index 35034e8354..155a6dc3d8 100644 --- a/pcapkit/vendor/pcapng/verdict_type.py +++ b/pcapkit/vendor/pcapng/verdict_type.py @@ -67,7 +67,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in DATA.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/reg/ethertype.py b/pcapkit/vendor/reg/ethertype.py index cdadf7d459..44a07d1207 100644 --- a/pcapkit/vendor/reg/ethertype.py +++ b/pcapkit/vendor/reg/ethertype.py @@ -32,6 +32,20 @@ class EtherType(Vendor): #: Link to registry. LINK = 'https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers-1.csv' + #: Row labels that the historical Neil Sembower list itself marks as + #: carrying no real assignment -- a company holding the block but naming + #: nothing (``DEC Unassigned``), or a range the list says is dead/invalid + #: outright -- rather than a proprietary protocol's real name. Per the + #: owner's ruling on #775/#847: a proprietary protocol's company name IS + #: the final concrete name (no public name will ever exist), so every + #: *other* row here still mints; only these read as notation for the + #: reader and get a throwaway :meth:`~pcapkit.corekit.enum.EnumRegistry. + #: _unregistered_member` instead. + UNASSIGNED_ROW_NAMES = frozenset({ + 'DEC Unassigned', + 'Old Xerox Experimental values. Invalid as an Ethertype since 1983.', + }) + def count(self, data: 'list[str]') -> 'Counter[str]': """Count field records. @@ -113,7 +127,10 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if 0x{start} <= value <= 0x{stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_0x%s' % hex(value)[2:].upper().zfill(4), value)") # pylint: disable=line-too-long + if name in self.UNASSIGNED_ROW_NAMES: + miss.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')") + else: + miss.append(f" return extend_enum(cls, '{self.safe_name(name)}_0x%s' % hex(value)[2:].upper().zfill(4), value)") # pylint: disable=line-too-long return enum, miss diff --git a/pcapkit/vendor/reg/linktype.py b/pcapkit/vendor/reg/linktype.py index 1944fcd206..ba0fe4ad2f 100644 --- a/pcapkit/vendor/reg/linktype.py +++ b/pcapkit/vendor/reg/linktype.py @@ -65,7 +65,7 @@ def process(self, data: 'list[Tag]') -> 'tuple[list[str], list[str]]': enum = [] # type: list[str] legacy = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] # Value-aware guard for the ``sink`` decision below (GitHub issue #852, diff --git a/pcapkit/vendor/reg/transtype.py b/pcapkit/vendor/reg/transtype.py index 69d0fd66e4..1e79b80e83 100644 --- a/pcapkit/vendor/reg/transtype.py +++ b/pcapkit/vendor/reg/transtype.py @@ -103,7 +103,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/tcp/checksum.py b/pcapkit/vendor/tcp/checksum.py index 66526d3857..21b1ba7ede 100644 --- a/pcapkit/vendor/tcp/checksum.py +++ b/pcapkit/vendor/tcp/checksum.py @@ -68,7 +68,7 @@ def process(self, data: 'dict[int, str]') -> 'tuple[list[str], list[str]]': # t """ enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned_%d' % value, value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for code, name in data.items(): renm = self.rename(name, code) # type: ignore[arg-type] diff --git a/pcapkit/vendor/tcp/mp_tcp_option.py b/pcapkit/vendor/tcp/mp_tcp_option.py index 2b6906ab8c..b00bbc234e 100644 --- a/pcapkit/vendor/tcp/mp_tcp_option.py +++ b/pcapkit/vendor/tcp/mp_tcp_option.py @@ -82,7 +82,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/tcp/option.py b/pcapkit/vendor/tcp/option.py index 0ab0540afa..f645d51390 100644 --- a/pcapkit/vendor/tcp/option.py +++ b/pcapkit/vendor/tcp/option.py @@ -95,7 +95,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': miss.append(f'if {start} <= value <= {stop}:') miss.append(f' #: {desc}') - miss.append(f" return extend_enum(cls, '{name}_%d' % value, value)") + miss.append(f" return cls._unregistered_member(value, '{name}')") return enum, miss diff --git a/pcapkit/vendor/vlan/priority_level.py b/pcapkit/vendor/vlan/priority_level.py index ca03b217f0..cfb450a5a3 100644 --- a/pcapkit/vendor/vlan/priority_level.py +++ b/pcapkit/vendor/vlan/priority_level.py @@ -66,7 +66,7 @@ def process(self, soup: 'BeautifulSoup') -> 'tuple[list[str], list[str]]': # py enum = [] # type: list[str] miss = [ - "return extend_enum(cls, 'Unassigned [0b%s]' % bin(value)[2:].zfill(3), value)", + "return cls._unregistered_member(value, 'Unassigned')", ] for item in content: line = item.find_all('td') diff --git a/tests/const/test_const_enum_builtin_parity.py b/tests/const/test_const_enum_builtin_parity.py index ccce746d7b..0162092eff 100644 --- a/tests/const/test_const_enum_builtin_parity.py +++ b/tests/const/test_const_enum_builtin_parity.py @@ -87,11 +87,22 @@ "raised AttributeError: 'int' object has no attribute 'upper'"), ) -#: The registries whose ``_missing_`` ends in :func:`~aenum.extend_enum`, so an -#: unassigned value in their span is *registered* rather than rejected. This is -#: the deliberate divergence from the built-in, not an oversight: their backing -#: registries carry open "Unassigned" spans that a capture can legitimately -#: contain. They still reject a *negative* value, which no span covers. +#: The registries whose ``_missing_`` resolves an unassigned value in their +#: span rather than rejecting it -- this is the deliberate divergence from the +#: built-in, not an oversight: their backing registries carry open +#: "Unassigned" spans that a capture can legitimately contain. They still +#: reject a *negative* value, which no span covers. +#: +#: Only :class:`~pcapkit.const.mh.cga_type.CGAType` still ends in +#: :func:`~aenum.extend_enum` (its mint is not an IANA-style range at all, so +#: GitHub issues #775/#847's ruling never touched it). +#: :class:`~pcapkit.const.ipv4.protection_authority.ProtectionAuthority` +#: resolves the same way but no longer *registers* -- its bare ``Unassigned`` +#: converted, so it now goes through ``_unregistered_member`` and the +#: resolution is not permanent; see +#: :meth:`ConstEnumRegisterFallbackTests.test_protection_authority_now_ +#: resolves_without_extending`. The name is kept for both because this set's +#: own test only checks "does it raise", not "does it grow". EXPECTED_TO_REGISTER = frozenset({ 'pcapkit.const.ipv4.protection_authority.ProtectionAuthority', 'pcapkit.const.mh.cga_type.CGAType', @@ -688,10 +699,21 @@ def test_the_guard_leaves_the_other_lookup_paths_alone(self) -> None: Flags.get(UNRESOLVABLE) def test_the_auto_extending_integer_registries_still_extend(self) -> None: - from pcapkit.const.ipv4.protection_authority import ProtectionAuthority + """:class:`~pcapkit.const.mh.cga_type.CGAType` is the one true survivor + here: its ``Tag_`` mint is not an IANA-style range at all (a CGA + extension type tag is a collision-avoidance random 128-bit value), so + GitHub issues #775/#847's mint-criterion ruling never touched it. + + :class:`~pcapkit.const.ipv4.protection_authority.ProtectionAuthority` + used to stand here beside it -- its own unbounded ``_missing_`` also + auto-extended for any non-negative integer -- but its label is a bare + ``Unassigned``, which the ruling converts; see + :meth:`test_protection_authority_now_resolves_without_extending` for + its replacement. + """ from pcapkit.const.mh.cga_type import CGAType - for obj in (ProtectionAuthority, CGAType): + for obj in (CGAType,): with self.subTest(enum=_qualname(obj)): before = len(obj.__members__) registered = obj(UNRESOLVABLE) @@ -702,6 +724,29 @@ def test_the_auto_extending_integer_registries_still_extend(self) -> None: with self.assertRaises(ValueError): obj(-1) + def test_protection_authority_now_resolves_without_extending(self) -> None: + """The other half of the split :meth:`test_the_auto_extending_integer_ + registries_still_extend` used to cover as one case. Still resolves any + non-negative integer -- its ``_missing_`` bound is unchanged -- but + since #775/#847 that no longer mints a permanent member: a bare + ``Unassigned`` is a notation for the reader, not a name IANA assigned, + so two lookups of the same value are equal but no longer identical.""" + from pcapkit.const.ipv4.protection_authority import ProtectionAuthority + + before = len(ProtectionAuthority.__members__) + first = ProtectionAuthority(UNRESOLVABLE) + second = ProtectionAuthority(UNRESOLVABLE) + + self.assertEqual(len(ProtectionAuthority.__members__), before) + self.assertEqual(int(first), UNRESOLVABLE) + self.assertEqual(first, second) + self.assertIsNot(first, second) + self.assertNotIn(UNRESOLVABLE, ProtectionAuthority._value2member_map_) + + # ... and still reject a value no span covers. + with self.assertRaises(ValueError): + ProtectionAuthority(-1) + def test_apptype_still_registers_an_unassigned_port(self) -> None: """GitHub issue #584's machinery, which runs through ``_missing_``.""" from pcapkit.const.reg.apptype import AppType, TransportProtocol diff --git a/tests/const/test_const_enum_get.py b/tests/const/test_const_enum_get.py index 92a98a0462..8064c69f27 100644 --- a/tests/const/test_const_enum_get.py +++ b/tests/const/test_const_enum_get.py @@ -70,8 +70,7 @@ UNRESOLVABLE = 1 << 70 #: Enums whose integer path resolves *anything* rather than raising, so there is -#: no fallback for ``default`` to supply: both auto-extend their unassigned spans -#: across the full integer range. +#: no fallback for ``default`` to supply. #: #: :class:`~pcapkit.const.tcp.flags.Flags` was a third entry until GitHub issue #: #647. It resolved anything for a different reason -- it defined no @@ -79,6 +78,16 @@ #: and ``Flags(-1)`` read back as every TCP header flag set at once. It now #: bounds its own domain like the rest of the tree and so belongs in the sweep #: below rather than in this set. +#: +#: Both used to auto-*extend* their unassigned span across the full integer +#: range, via :func:`~aenum.extend_enum`. GitHub issues #775/#847's +#: mint-criterion ruling converted :class:`~pcapkit.const.ipv4. +#: protection_authority.ProtectionAuthority`'s bare ``Unassigned`` label, so it +#: now resolves via :meth:`~pcapkit.corekit.enum.EnumRegistry. +#: _unregistered_member` instead -- it still resolves anything (the property +#: that excuses it from the sweep below), it just no longer extends. +#: :class:`~pcapkit.const.mh.cga_type.CGAType` is untouched: its ``Tag_`` +#: mint is not an IANA-style range at all, so the ruling never applied. EXPECTED_TO_RESOLVE_ANYTHING = frozenset({ 'pcapkit.const.ipv4.protection_authority.ProtectionAuthority', 'pcapkit.const.mh.cga_type.CGAType', @@ -98,6 +107,24 @@ 'pcapkit.const.reg.apptype.apptype.TransportProtocol', }) +#: :class:`~pcapkit.const.pcapng.filter_type.FilterType` declares *no* static +#: members at all -- every one of its 256 codes reaches ``_missing_``. Before +#: GitHub issues #775/#847's ruling that was masked by an accident: importing +#: :mod:`pcapkit.protocols.misc.pcapng` evaluates ``Enum_FilterType(0)`` as a +#: default argument at class-definition time, which used to permanently mint +#: ``'Unassigned_0'`` as a side effect of merely importing the library -- +#: leaving exactly one member for this sweep's ``next(iter(obj))`` fallback to +#: find. The ruling correctly converted FilterType's bare ``Unassigned`` label, +#: so that same import no longer mints anything, and the registry is now +#: genuinely empty: :func:`next` on it raises :exc:`StopIteration`, with no +#: value at all that ``obj(fallback)`` would resolve to a *cached* identity +#: for. Excused from the main sweep for that reason and covered by its own +#: test instead, :meth:`ConstEnumGetDefaultTests. +#: test_filter_type_default_is_consulted_without_a_cached_fallback`. +EXPECTED_WITHOUT_A_CACHEABLE_FALLBACK = frozenset({ + 'pcapkit.const.pcapng.filter_type.FilterType', +}) + def _iter_const_enums() -> 'list[type]': """Every :class:`~aenum.IntEnum` and :class:`~aenum.IntFlag` under :mod:`pcapkit.const`. @@ -226,10 +253,11 @@ def test_the_two_unverified_enums_from_the_issue(self) -> None: def test_the_sweep_size_is_pinned(self) -> None: # If this drifts, a const enum was added, removed or renamed, and the - # two exception sets below need a fresh look rather than a silent pass. + # exception sets below need a fresh look rather than a silent pass. names = {_qualname(obj) for obj in self.enums} self.assertEqual(len(self.enums), 118) - for expected in (EXPECTED_TO_RESOLVE_ANYTHING, EXPECTED_WITHOUT_AN_INTEGER_DEFAULT): + for expected in (EXPECTED_TO_RESOLVE_ANYTHING, EXPECTED_WITHOUT_AN_INTEGER_DEFAULT, + EXPECTED_WITHOUT_A_CACHEABLE_FALLBACK): self.assertTrue(expected.issubset(names), f'sweep is missing: {expected - names}') @@ -252,37 +280,48 @@ def test_every_integer_path_consults_the_default(self) -> None: # subject is something else, and for these two the ``try`` # never raises, so it would assert nothing about the fix. continue + if qualname in EXPECTED_WITHOUT_A_CACHEABLE_FALLBACK: + # Covered by its own test below: it raises for UNRESOLVABLE + # like the rest of this sweep, but has no real member to use + # as ``fallback`` -- see the set's own comment. + continue with self.subTest(enum=qualname): with self.assertRaises(ValueError): obj.get(UNRESOLVABLE) fallback = next(iter(obj)).value self.assertIs(obj.get(UNRESOLVABLE, fallback), obj(fallback)) covered += 1 - # 111 rather than 110 since GitHub issue #647 gave - # :class:`~pcapkit.const.tcp.flags.Flags` a range guard, which moved it - # out of ``EXPECTED_TO_RESOLVE_ANYTHING`` and into this sweep. - self.assertEqual(covered, 111) + # 111 from GitHub issue #647, which gave + # :class:`~pcapkit.const.tcp.flags.Flags` a range guard and moved it + # out of ``EXPECTED_TO_RESOLVE_ANYTHING`` and into this sweep; minus 1 + # for ``FilterType``, which #775/#847's ruling moved the other way -- + # it used to be counted here only because an import-time side effect + # (see ``EXPECTED_WITHOUT_A_CACHEABLE_FALLBACK``) happened to leave it + # one real member to use as ``fallback``, and the ruling removed that + # side effect along with the mint it came from. + self.assertEqual(covered, 110) def test_the_always_resolving_registries_have_nothing_to_fall_back_to(self) -> None: """The two registries excused from the sweep, and why. - Their ``_missing_`` extends for *any* integer, so the integer path never - raises and ``default`` has nothing to supply. Asserted rather than merely - listed, so ``EXPECTED_TO_RESOLVE_ANYTHING`` cannot quietly grow to hide a - registry that does raise. - - Kept out of the sweep because probing them *mutates* the registry: the - call permanently registers a member on a module-global class. That is - done deliberately here, and ``setUpClass`` registers a class cleanup that - purges :mod:`pcapkit` afterwards so the pollution cannot reach another - module. - - Measured: ``ProtectionAuthority`` grows 8 members to 9 and ``CGAType`` 7 - to 8, because their ``_missing_`` calls ``extend_enum``. The shared - assertion below is still "resolves" rather than "extends" because that is - the property excusing them, and it is the property - :class:`~pcapkit.const.tcp.flags.Flags` stopped having in GitHub issue - #647 -- it resolved without extending, and now does neither. + Their ``_missing_`` resolves for *any* integer, so the integer path + never raises and ``default`` has nothing to supply. Asserted rather + than merely listed, so ``EXPECTED_TO_RESOLVE_ANYTHING`` cannot quietly + grow to hide a registry that does raise. + + Probing :class:`~pcapkit.const.mh.cga_type.CGAType` still *mutates* + the registry: the call permanently registers a member on a + module-global class, because its mint is untouched by GitHub issues + #775/#847's ruling. That is done deliberately here, and + ``setUpClass`` registers a class cleanup that purges :mod:`pcapkit` + afterwards so the pollution cannot reach another module. + :class:`~pcapkit.const.ipv4.protection_authority.ProtectionAuthority` + no longer mutates anything -- its bare ``Unassigned`` converted, so it + resolves through a throwaway pseudo-member instead -- which is why the + identity check below only applies to ``CGAType``. + + Measured: ``CGAType`` still grows 7 members to 8; ``ProtectionAuthority`` + stays at 8. """ for qualname in sorted(EXPECTED_TO_RESOLVE_ANYTHING): module_name, _, class_name = qualname.rpartition('.') @@ -294,8 +333,34 @@ def test_the_always_resolving_registries_have_nothing_to_fall_back_to(self) -> N self.assertIsNotNone(resolved) self.assertEqual(int(resolved), UNRESOLVABLE) # It resolves with or without a default, so the sentinel branch - # this change added is never reached for these two. - self.assertIs(resolved, obj.get(UNRESOLVABLE, 0)) + # this change added is never reached for either of them. + self.assertEqual(resolved, obj.get(UNRESOLVABLE, 0)) + if qualname == 'pcapkit.const.mh.cga_type.CGAType': + # Still mints permanently -- identity holds. + self.assertIs(resolved, obj.get(UNRESOLVABLE, 0)) + else: + # Converted: a fresh, equal-but-not-identical pseudo-member + # every time, and the registry never grows for it. + self.assertIsNot(resolved, obj.get(UNRESOLVABLE, 0)) + + def test_filter_type_default_is_consulted_without_a_cached_fallback(self) -> None: + """:class:`~pcapkit.const.pcapng.filter_type.FilterType`'s own + replacement for the sweep above -- see + :data:`EXPECTED_WITHOUT_A_CACHEABLE_FALLBACK` for why it needs one.""" + from pcapkit.const.pcapng.filter_type import FilterType + + with self.assertRaises(ValueError): + FilterType.get(UNRESOLVABLE) + + # 0 is in-bounds (0x00-0xFF) but not a real member either -- FilterType + # declares none -- so this resolves via the same converted pseudo-member + # path as UNRESOLVABLE-with-a-default does, not via a cached identity. + before = len(FilterType.__members__) + resolved = FilterType.get(UNRESOLVABLE, 0) + self.assertEqual(int(resolved), 0) + self.assertEqual(resolved, FilterType(0)) + self.assertIsNot(resolved, FilterType(0)) + self.assertEqual(len(FilterType.__members__), before) @unittest.skipUnless(importlib.util.find_spec('requests') is not None, 'pcapkit.vendor needs requests') diff --git a/tests/const/test_const_enum_no_mint.py b/tests/const/test_const_enum_no_mint.py index 6d4c219221..6d9c43ae5d 100644 --- a/tests/const/test_const_enum_no_mint.py +++ b/tests/const/test_const_enum_no_mint.py @@ -22,6 +22,27 @@ the 12 vendor files that replace the shared template wholesale (and whatever they generate) are out of scope and untouched. +Tier 1 fixed the *mechanism* (a lookup should never mint); it did not decide, +registry by registry, which of the remaining ``_missing_`` bodies mint +something worth keeping. That is tier 2, decided on #775 and carried out on +#847: the owner's ruling, verbatim, is *"a final concrete assigned name -> +mint; a notation for the readers -> unmint"*. Applied registry by registry to +every ``_missing_`` that still called :func:`~aenum.extend_enum` -- measured +at exactly 89 modules by an AST walk over ``pcapkit/const/*.py`` (not the +"~92" an earlier pass in this programme estimated) -- the ruling converted 82 +of them outright (172 branches, :data:`RULING_CONVERTED_REGISTRIES` below), +left :class:`~pcapkit.const.reg.ethertype.EtherType` and +:class:`~pcapkit.const.ipx.socket.Socket` *mixed* (each keeps some branches +minting and converts others -- see :data:`ETHERTYPE_UNASSIGNED_PROBES` and +:data:`IPX_SOCKET_UNASSIGNED_PROBES`), and left 9 classes across 6 files +untouched because they do not inherit :class:`~pcapkit.corekit.enum. +EnumRegistry` and so have no ``_unregistered_member`` to convert to until +GitHub issue #860 lands (blocked on #859); :class:`~pcapkit.const.reg. +apptype.apptype.AppType` is the largest of those at 766 still-minting +branches. :class:`~pcapkit.const.mh.cga_type.CGAType` keeps minting too, but +for a different reason: its ``Tag_`` mint is not an IANA-style +range at all (see its own module for why), so the ruling never touched it. + """ from __future__ import annotations @@ -30,6 +51,7 @@ import inspect import pathlib import re +import textwrap import unittest from typing import TYPE_CHECKING @@ -211,6 +233,299 @@ def _first_unassigned_value(cls: 'type') -> 'int': return int(match.group(1)) +#: (module, class name) for every one of the 82 registries the owner's +#: #775/#847 ruling converted outright: every ``_missing_`` branch that used +#: to mint via :func:`~aenum.extend_enum` now returns :meth:`~pcapkit.corekit. +#: enum.EnumRegistry._unregistered_member` instead, because what it minted was +#: a bare status word (``Unassigned``, ``Reserved [...]``, ``Reserved for +#: Private/Experimental Use``, ``Unspecified in the IANA registry``, and +#: similar) rather than a name anyone assigned. Derived from the same AST walk +#: that measured 89 modules still minting on ``main`` before this change: 82 +#: of the 89 are here, including the two *mixed* registries (:class:`~pcapkit. +#: const.reg.ethertype.EtherType` and :class:`~pcapkit.const.ipx.socket. +#: Socket`, which convert some branches and keep minting others -- see +#: :data:`ETHERTYPE_UNASSIGNED_PROBES` and :data:`IPX_SOCKET_UNASSIGNED_ +#: PROBES`). The other 7 of the 89 are untouched: 6 files on classes that do +#: not inherit :class:`EnumRegistry` yet and so have no ``_unregistered_ +#: member`` to convert to (:class:`~pcapkit.const.reg.apptype.apptype. +#: AppType`, :class:`~pcapkit.const.http.status_code.StatusCode`, :mod: +#: `pcapkit.const.ftp.return_code`, :mod:`pcapkit.const.ftp.command`, +#: :class:`~pcapkit.const.http.method.Method`, :class:`~pcapkit.const.pcapng. +#: option_type.OptionType` -- see the module docstring), plus :class: +#: `~pcapkit.const.mh.cga_type.CGAType`, which the ruling never touched +#: because its mint is not an IANA-style range at all. +RULING_CONVERTED_REGISTRIES = ( + ('pcapkit.const.esp.cipher', 'Cipher'), + ('pcapkit.const.esp.integrity', 'Integrity'), + ('pcapkit.const.hip.eddsa_curve', 'EdDSACurve'), + ('pcapkit.const.hip.group', 'Group'), + ('pcapkit.const.hip.packet', 'Packet'), + ('pcapkit.const.hip.parameter', 'Parameter'), + ('pcapkit.const.http.error_code', 'ErrorCode'), + ('pcapkit.const.http.frame', 'Frame'), + ('pcapkit.const.http.setting', 'Setting'), + ('pcapkit.const.ipv4.classification_level', 'ClassificationLevel'), + ('pcapkit.const.ipv4.option_class', 'OptionClass'), + ('pcapkit.const.ipv4.option_number', 'OptionNumber'), + ('pcapkit.const.ipv4.protection_authority', 'ProtectionAuthority'), + ('pcapkit.const.ipv4.qs_function', 'QSFunction'), + ('pcapkit.const.ipv4.router_alert', 'RouterAlert'), + ('pcapkit.const.ipv4.tos_del', 'ToSDelay'), + ('pcapkit.const.ipv4.tos_ecn', 'ToSECN'), + ('pcapkit.const.ipv4.tos_pre', 'ToSPrecedence'), + ('pcapkit.const.ipv4.tos_rel', 'ToSReliability'), + ('pcapkit.const.ipv4.tos_thr', 'ToSThroughput'), + ('pcapkit.const.ipv4.ts_flag', 'TSFlag'), + ('pcapkit.const.ipv6.option', 'Option'), + ('pcapkit.const.ipv6.option_action', 'OptionAction'), + ('pcapkit.const.ipv6.qs_function', 'QSFunction'), + ('pcapkit.const.ipv6.router_alert', 'RouterAlert'), + ('pcapkit.const.ipv6.routing', 'Routing'), + ('pcapkit.const.ipv6.seed_id', 'SeedID'), + ('pcapkit.const.ipv6.smf_dpd_mode', 'SMFDPDMode'), + ('pcapkit.const.ipv6.tagger_id', 'TaggerID'), + ('pcapkit.const.ipx.packet', 'Packet'), + ('pcapkit.const.l2tp.type', 'Type'), + ('pcapkit.const.mh.access_type', 'AccessType'), + ('pcapkit.const.mh.ack_status_code', 'ACKStatusCode'), + ('pcapkit.const.mh.ani_suboption', 'ANISuboption'), + ('pcapkit.const.mh.auth_subtype', 'AuthSubtype'), + ('pcapkit.const.mh.binding_error', 'BindingError'), + ('pcapkit.const.mh.binding_revocation', 'BindingRevocation'), + ('pcapkit.const.mh.cga_extension', 'CGAExtension'), + ('pcapkit.const.mh.cga_sec', 'CGASec'), + ('pcapkit.const.mh.dhcp_support_mode', 'DHCPSupportMode'), + ('pcapkit.const.mh.dns_status_code', 'DNSStatusCode'), + ('pcapkit.const.mh.dsmip6_tls_packet', 'DSMIP6TLSPacket'), + ('pcapkit.const.mh.dsmipv6_home_address', 'DSMIPv6HomeAddress'), + ('pcapkit.const.mh.enumerating_algorithm', 'EnumeratingAlgorithm'), + ('pcapkit.const.mh.fb_ack_status', 'FlowBindingACKStatus'), + ('pcapkit.const.mh.fb_action', 'FlowBindingAction'), + ('pcapkit.const.mh.fb_indication_trigger', 'FlowBindingIndicationTrigger'), + ('pcapkit.const.mh.fb_type', 'FlowBindingType'), + ('pcapkit.const.mh.flow_id_status', 'FlowIDStatus'), + ('pcapkit.const.mh.flow_id_suboption', 'FlowIDSuboption'), + ('pcapkit.const.mh.handoff_type', 'HandoffType'), + ('pcapkit.const.mh.handover_ack_status', 'HandoverACKStatus'), + ('pcapkit.const.mh.handover_initiate_status', 'HandoverInitiateStatus'), + ('pcapkit.const.mh.home_address_reply', 'HomeAddressReply'), + ('pcapkit.const.mh.lla_code', 'LLACode'), + ('pcapkit.const.mh.lma_mag_suboption', 'LMAControlledMAGSuboption'), + ('pcapkit.const.mh.mn_group_id', 'MNGroupID'), + ('pcapkit.const.mh.mn_id_subtype', 'MNIDSubtype'), + ('pcapkit.const.mh.operator_id', 'OperatorID'), + ('pcapkit.const.mh.option', 'Option'), + ('pcapkit.const.mh.packet', 'Packet'), + ('pcapkit.const.mh.qos_attribute', 'QoSAttribute'), + ('pcapkit.const.mh.revocation_status_code', 'RevocationStatusCode'), + ('pcapkit.const.mh.revocation_trigger', 'RevocationTrigger'), + ('pcapkit.const.mh.status_code', 'StatusCode'), + ('pcapkit.const.mh.traffic_selector', 'TrafficSelector'), + ('pcapkit.const.mh.upa_status', 'UpdateNotificationACKStatus'), + ('pcapkit.const.mh.upn_reason', 'UpdateNotificationReason'), + ('pcapkit.const.pcapng.block_type', 'BlockType'), + ('pcapkit.const.pcapng.filter_type', 'FilterType'), + ('pcapkit.const.pcapng.hash_algorithm', 'HashAlgorithm'), + ('pcapkit.const.pcapng.record_type', 'RecordType'), + ('pcapkit.const.pcapng.secrets_type', 'SecretsType'), + ('pcapkit.const.pcapng.verdict_type', 'VerdictType'), + ('pcapkit.const.reg.ethertype', 'EtherType'), + ('pcapkit.const.reg.linktype', 'LinkType'), + ('pcapkit.const.reg.transtype', 'TransType'), + ('pcapkit.const.tcp.checksum', 'Checksum'), + ('pcapkit.const.tcp.mp_tcp_option', 'MPTCPOption'), + ('pcapkit.const.tcp.option', 'Option'), + ('pcapkit.const.vlan.priority_level', 'PriorityLevel'), +) + +#: Subset of :data:`RULING_CONVERTED_REGISTRIES` whose converted branch a +#: generic "first branch that converts, by source order" probe can actually +#: exercise -- i.e. the registry's own bounds contain at least one value that +#: is not already a declared member, *and* nothing earlier in the same +#: ``_missing_`` masks it. Two different reasons hold registries out of this +#: list: +#: +#: * 13 have no reachable gap at all -- the same situation :data:`ALL_ +#: REGISTRIES` already documents for :class:`~pcapkit.const.hip.transport. +#: Transport`: every value inside the guard's own bounds names a real +#: member, so ``_missing_`` can never actually run for them (e.g. :class: +#: `~pcapkit.const.ipv4.tos_del.ToSDelay` is bounded to ``0 <= value <= 1`` +#: and both 0 and 1 are declared). They are proved by :class: +#: `RulingConversionSourceTests` (a source sweep) instead. +#: * :class:`~pcapkit.const.reg.ethertype.EtherType` is excluded for a third +#: reason: its *first* converted branch by source order ("Old Xerox +#: Experimental...", 0x0101-0x01FF) is itself unreachable, masked by the +#: wider 0x0000-0x05DC branch before it -- see :data:`ETHERTYPE_UNASSIGNED_ +#: PROBES`'s comment. A naive probe would silently exercise the wrong +#: branch, so :class:`EtherTypeMixedMintTests` covers it explicitly instead +#: (behaviourally for ``DEC Unassigned``, by source for the masked row). +#: +#: Derived the same way as :data:`RULING_CONVERTED_REGISTRIES`: computed once +#: by walking each candidate's own bounds for a gap, not hand-picked. +RULING_CONVERTED_WITH_REACHABLE_GAP = ( + ('pcapkit.const.esp.cipher', 'Cipher'), + ('pcapkit.const.esp.integrity', 'Integrity'), + ('pcapkit.const.hip.eddsa_curve', 'EdDSACurve'), + ('pcapkit.const.hip.group', 'Group'), + ('pcapkit.const.hip.packet', 'Packet'), + ('pcapkit.const.hip.parameter', 'Parameter'), + ('pcapkit.const.http.error_code', 'ErrorCode'), + ('pcapkit.const.http.frame', 'Frame'), + ('pcapkit.const.http.setting', 'Setting'), + ('pcapkit.const.ipv4.classification_level', 'ClassificationLevel'), + ('pcapkit.const.ipv4.option_number', 'OptionNumber'), + ('pcapkit.const.ipv4.qs_function', 'QSFunction'), + ('pcapkit.const.ipv4.router_alert', 'RouterAlert'), + ('pcapkit.const.ipv4.ts_flag', 'TSFlag'), + ('pcapkit.const.ipv6.option', 'Option'), + ('pcapkit.const.ipv6.qs_function', 'QSFunction'), + ('pcapkit.const.ipv6.router_alert', 'RouterAlert'), + ('pcapkit.const.ipv6.routing', 'Routing'), + ('pcapkit.const.ipv6.tagger_id', 'TaggerID'), + ('pcapkit.const.ipx.packet', 'Packet'), + ('pcapkit.const.ipx.socket', 'Socket'), + ('pcapkit.const.mh.access_type', 'AccessType'), + ('pcapkit.const.mh.ack_status_code', 'ACKStatusCode'), + ('pcapkit.const.mh.ani_suboption', 'ANISuboption'), + ('pcapkit.const.mh.auth_subtype', 'AuthSubtype'), + ('pcapkit.const.mh.binding_error', 'BindingError'), + ('pcapkit.const.mh.binding_revocation', 'BindingRevocation'), + ('pcapkit.const.mh.cga_extension', 'CGAExtension'), + ('pcapkit.const.mh.cga_sec', 'CGASec'), + ('pcapkit.const.mh.dns_status_code', 'DNSStatusCode'), + ('pcapkit.const.mh.dsmip6_tls_packet', 'DSMIP6TLSPacket'), + ('pcapkit.const.mh.dsmipv6_home_address', 'DSMIPv6HomeAddress'), + ('pcapkit.const.mh.enumerating_algorithm', 'EnumeratingAlgorithm'), + ('pcapkit.const.mh.fb_ack_status', 'FlowBindingACKStatus'), + ('pcapkit.const.mh.fb_action', 'FlowBindingAction'), + ('pcapkit.const.mh.fb_indication_trigger', 'FlowBindingIndicationTrigger'), + ('pcapkit.const.mh.fb_type', 'FlowBindingType'), + ('pcapkit.const.mh.flow_id_status', 'FlowIDStatus'), + ('pcapkit.const.mh.flow_id_suboption', 'FlowIDSuboption'), + ('pcapkit.const.mh.handoff_type', 'HandoffType'), + ('pcapkit.const.mh.handover_ack_status', 'HandoverACKStatus'), + ('pcapkit.const.mh.handover_initiate_status', 'HandoverInitiateStatus'), + ('pcapkit.const.mh.home_address_reply', 'HomeAddressReply'), + ('pcapkit.const.mh.lla_code', 'LLACode'), + ('pcapkit.const.mh.lma_mag_suboption', 'LMAControlledMAGSuboption'), + ('pcapkit.const.mh.mn_group_id', 'MNGroupID'), + ('pcapkit.const.mh.mn_id_subtype', 'MNIDSubtype'), + ('pcapkit.const.mh.operator_id', 'OperatorID'), + ('pcapkit.const.mh.option', 'Option'), + ('pcapkit.const.mh.packet', 'Packet'), + ('pcapkit.const.mh.qos_attribute', 'QoSAttribute'), + ('pcapkit.const.mh.revocation_status_code', 'RevocationStatusCode'), + ('pcapkit.const.mh.revocation_trigger', 'RevocationTrigger'), + ('pcapkit.const.mh.status_code', 'StatusCode'), + ('pcapkit.const.mh.traffic_selector', 'TrafficSelector'), + ('pcapkit.const.mh.upa_status', 'UpdateNotificationACKStatus'), + ('pcapkit.const.mh.upn_reason', 'UpdateNotificationReason'), + ('pcapkit.const.pcapng.block_type', 'BlockType'), + ('pcapkit.const.pcapng.filter_type', 'FilterType'), + ('pcapkit.const.pcapng.hash_algorithm', 'HashAlgorithm'), + ('pcapkit.const.pcapng.record_type', 'RecordType'), + ('pcapkit.const.pcapng.secrets_type', 'SecretsType'), + ('pcapkit.const.pcapng.verdict_type', 'VerdictType'), + ('pcapkit.const.reg.linktype', 'LinkType'), + ('pcapkit.const.reg.transtype', 'TransType'), + ('pcapkit.const.tcp.checksum', 'Checksum'), + ('pcapkit.const.tcp.mp_tcp_option', 'MPTCPOption'), + ('pcapkit.const.tcp.option', 'Option'), +) + +#: :class:`~pcapkit.const.reg.ethertype.EtherType` probes for the owner's +#: ruling: ``DEC Unassigned`` and the historical list's own "Old Xerox +#: Experimental values. Invalid as an Ethertype since 1983." both convert, +#: because the label itself says nothing was assigned. Every *other* named +#: block -- companies the historical list attributes a real code range to -- +#: stays a mint; :data:`ETHERTYPE_KEPT_PROBE` pins one (``Xyplex``) as a +#: regression guard. +#: +#: "Old Xerox Experimental" (0x0101-0x01FF) is not behaviourally probeable: +#: it is a strict subset of the earlier, wider "IEEE802.3 Length Field" branch +#: (0x0000-0x05DC), which the ``_missing_`` if-chain matches first and so +#: masks it completely -- the same shape of pre-existing ordering bug GitHub +#: issue #841 found in :mod:`pcapkit.const.ipx.socket`, present on ``main`` +#: before this change and not part of #775/#847's ruling, so it is left as a +#: follow-up rather than reordered here. :class:`EtherTypeMixedMintTests` +#: proves that row by source instead of by calling it. +ETHERTYPE_UNASSIGNED_PROBES = { + 0x8039: 'DEC_Unassigned', +} +ETHERTYPE_MASKED_UNASSIGNED_LABEL = 'Old_Xerox_Experimental_values_Invalid_as_an_Ethertype_since_1983' +ETHERTYPE_KEPT_PROBE = (0x0888, 'Xyplex_0x0888') + +#: :class:`~pcapkit.const.ipx.socket.Socket` probes for the owner's ruling: +#: ``Experimental`` and the three "who may claim this pool" policy labels +#: convert; ``Registered by Xerox`` -- a real ownership fact, not a status +#: word -- keeps minting, pinned by :data:`IPX_SOCKET_KEPT_PROBE`. +IPX_SOCKET_UNASSIGNED_PROBES = { + 0x0025: 'Experimental', + 0x4001: 'Dynamically Assigned Socket Numbers', + 0x8001: 'Statically Assigned Socket Numbers', + 0x0BBA: 'Dynamically Assigned', +} +IPX_SOCKET_KEPT_PROBE = (0x0010, 'Registered by Xerox_0x0010') + + +def _first_unregistered_value(cls: 'type') -> 'Optional[int]': + """The first value :meth:`cls._missing_ ` converts to a + throwaway :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` + pseudo-member, read from the class's own compiled ``_missing_`` by AST + rather than hardcoded. + + Handles both shapes tier 2 produced: a per-range branch (``if lo <= value + <= hi: ... return cls._unregistered_member(...)``), whose lower bound is + the probe; and an unconditional mint straight after the guard (no range + branch of its own), for which any in-bounds value not already a member + will do -- so this scans forward from the guard's own lower bound for the + first gap. Returns :data:`None` if neither shape is reachable at all + (every in-bounds value is already a declared member), which + :data:`RULING_CONVERTED_WITH_REACHABLE_GAP` excludes from behavioural + testing for exactly that reason. + + """ + source = inspect.getsource(cls._missing_) # type: ignore[attr-defined] + tree = ast.parse(textwrap.dedent(source)) + func = tree.body[0] + + for node in ast.walk(func): + if not isinstance(node, ast.If): + continue + calls_unreg = any( + isinstance(n, ast.Call) and isinstance(n.func, ast.Attribute) + and n.func.attr == '_unregistered_member' + for n in ast.walk(node) + ) + if not calls_unreg: + continue + test = node.test + if isinstance(test, ast.Compare) and len(test.ops) == 2: + return ast.literal_eval(test.left) # type: ignore[no-any-return] + + bounds = None + for node in ast.walk(func): + if not isinstance(node, ast.If): + continue + test = node.test + if isinstance(test, ast.UnaryOp) and isinstance(test.op, ast.Not): + inner = test.operand + if isinstance(inner, ast.BoolOp) and isinstance(inner.op, ast.And): + for value in inner.values: + if isinstance(value, ast.Compare) and len(value.ops) == 2: + bounds = (ast.literal_eval(value.left), ast.literal_eval(value.comparators[-1])) + break + if bounds is not None: + break + if bounds is None: + return None + lo, hi = bounds + for probe in range(lo, min(hi, lo + 100000) + 1): + if probe not in cls._value2member_map_: # type: ignore[attr-defined] + return probe + return None + + def _purge_member(cls: 'type', name: 'str', value: 'int') -> 'None': """Undo an :func:`~aenum.extend_enum` so a test's explicit :meth:`register` call does not leak into the rest of the suite. @@ -448,13 +763,24 @@ class UnregisteredMemberNameIsBareTests(unittest.TestCase): than pinning one example -- and asserts that every ``cls._unregistered_member(...)`` call site passes a plain string literal with no ``%`` formatting. It therefore covers all 49 call sites - tier 1's follow-up touched, and any added by a later regeneration, - without caring which registry they belong to. A call site still using - ``extend_enum(...)`` -- the ~92 registries that still mint, such as - :mod:`pcapkit.const.mh` or :class:`~pcapkit.const.pcapng.block_type. - BlockType` -- is out of scope and untouched by this sweep, since a - minted name still needs its numeric suffix to avoid a genuine - ``__members__`` collision. + tier 1's follow-up touched, plus the 172 tier 2's #775/#847 ruling added + (221 total, measured on this tree -- see :data:`RULING_CONVERTED_ + REGISTRIES` above), and any added by a later regeneration, without caring + which registry they belong to. A call site still using ``extend_enum(...)`` + -- the 9 classes across 6 files tier 2 left untouched because they are not + :class:`~pcapkit.corekit.enum.EnumRegistry` yet (:class:`~pcapkit.const. + reg.apptype.apptype.AppType` and friends, see the module docstring), plus + the handful of still-minting branches on :class:`~pcapkit.const.reg. + ethertype.EtherType` and :class:`~pcapkit.const.ipx.socket.Socket` that the + ruling kept, plus :class:`~pcapkit.const.mh.cga_type.CGAType` -- is out of + scope and untouched by this sweep, since a minted name still needs its + numeric suffix to avoid a genuine ``__members__`` collision. + + (Corrected from an earlier draft of this docstring, which estimated + "~92 registries still mint" and named ``pcapkit.const.mh`` and + ``BlockType`` as examples -- both were converted by tier 2 and no longer + apply; the AST walk in the module docstring above measured the real + figure at 89.) """ @@ -489,12 +815,208 @@ def test_every_unregistered_member_call_passes_a_bare_name(self) -> None: offenders.append(f'{path.relative_to(repo_root)}:{node.lineno}: {segment}') # Sanity: the sweep itself must actually be exercising something -- - # tier 1's follow-up touched exactly 49 call sites across 21 files. - self.assertGreaterEqual(call_count, 49, - f'expected at least 49 _unregistered_member call sites, found {call_count}') + # tier 1's follow-up touched exactly 49 call sites across 21 files, + # and tier 2's #775/#847 ruling added 172 more across 82 files, for + # 221 total measured on this tree. + self.assertGreaterEqual(call_count, 221, + f'expected at least 221 _unregistered_member call sites, found {call_count}') self.assertEqual(offenders, [], 'found _unregistered_member call(s) with a non-bare name:\n' + '\n'.join(offenders)) +class RulingConversionDoesNotMintTests(unittest.TestCase): + """Tier 2's #775/#847 ruling, behaviourally: a value that used to mint a + bare status word must now come back as a throwaway pseudo-member instead, + the same regression :class:`UnassignedRangeDoesNotMintTests` above proves + for tier 1's 21. Swept across :data:`RULING_CONVERTED_WITH_REACHABLE_GAP` + -- the 69 of the 82 converted registries whose branch a real lookup can + actually reach; the other 13 are proved by source instead, in + :class:`RulingConversionSourceTests` below.""" + + if TYPE_CHECKING: + registries: 'list[type]' + + @classmethod + def setUpClass(cls) -> None: + snapshot = snapshot_modules(ISOLATED_PREFIXES) + purge_modules(['pcapkit']) + cls.registries = [ + getattr(importlib.import_module(module_name), class_name) + for module_name, class_name in RULING_CONVERTED_WITH_REACHABLE_GAP + ] + cls.addClassCleanup(restore_modules, snapshot, ISOLATED_PREFIXES) + + def test_converted_value_does_not_mint(self) -> None: + for cls in self.registries: + with self.subTest(registry=cls.__qualname__): + value = _first_unregistered_value(cls) + self.assertIsNotNone(value, f'{cls.__qualname__} has no reachable converted branch') + self.assertNotIn(value, cls._value2member_map_) # type: ignore[attr-defined] + + before = len(cls.__members__) + member = cls(value) + after = len(cls.__members__) + + self.assertEqual(member.value, value) + self.assertEqual(before, after) + self.assertNotIn(value, cls._value2member_map_) # type: ignore[attr-defined] + self.assertNotIn(member.name, cls.__members__) + + def test_repeated_lookup_does_not_grow_members(self) -> None: + for cls in self.registries: + with self.subTest(registry=cls.__qualname__): + value = _first_unregistered_value(cls) + self.assertIsNotNone(value, f'{cls.__qualname__} has no reachable converted branch') + before = len(cls.__members__) + + first = cls(value) + after_one = len(cls.__members__) + second = cls(value) + after_two = len(cls.__members__) + + self.assertEqual(before, after_one) + self.assertEqual(before, after_two) + self.assertEqual(first, second) + self.assertIsNot(first, second) + + +#: :class:`~pcapkit.const.reg.ethertype.EtherType` and :class:`~pcapkit.const. +#: ipx.socket.Socket` are the two *mixed* registries: most of their +#: ``_missing_`` legitimately keeps minting (real attributed names), so the +#: blanket "no extend_enum left" sweep below does not apply to them -- +#: :class:`EtherTypeMixedMintTests` and :class:`IPXSocketMixedMintTests` cover +#: their converted rows specifically instead. +_MIXED_REGISTRIES = frozenset({('pcapkit.const.reg.ethertype', 'EtherType'), ('pcapkit.const.ipx.socket', 'Socket')}) + + +class RulingConversionSourceTests(unittest.TestCase): + """Source-level proof for the 13 of :data:`RULING_CONVERTED_REGISTRIES` + with no reachable gap (every in-bounds value already names a real member, + so no lookup can exercise the branch either before or after this change) + -- and, as a completeness check, for the 80 wholly-converted registries: + none of their ``_missing_`` bodies may call :func:`~aenum.extend_enum` + any more. Excludes the two mixed registries -- see :data:`_MIXED_ + REGISTRIES` -- which keep some ``extend_enum`` calls by design.""" + + def test_no_reachable_gap_registries_no_longer_call_extend_enum(self) -> None: + # EtherType is also absent from RULING_CONVERTED_WITH_REACHABLE_GAP, + # but for the *masked-branch* reason documented on that data, not the + # no-gap-at-all reason this test is about -- and unlike the true 13 it + # still legitimately keeps other extend_enum calls, so it is excluded + # from this set too and covered by EtherTypeMixedMintTests instead. + excluded = set(RULING_CONVERTED_REGISTRIES) - set(RULING_CONVERTED_WITH_REACHABLE_GAP) - _MIXED_REGISTRIES + self.assertEqual(len(excluded), 13, 'expected exactly 13 registries with no reachable gap') + for module_name, class_name in sorted(excluded): + with self.subTest(registry=class_name): + cls = getattr(importlib.import_module(module_name), class_name) + source = inspect.getsource(cls._missing_) # type: ignore[attr-defined] + self.assertNotIn('extend_enum', source) + self.assertIn('_unregistered_member', source) + + def test_every_wholly_converted_registry_no_longer_calls_extend_enum(self) -> None: + for module_name, class_name in RULING_CONVERTED_REGISTRIES: + if (module_name, class_name) in _MIXED_REGISTRIES: + continue + with self.subTest(registry=class_name): + cls = getattr(importlib.import_module(module_name), class_name) + source = inspect.getsource(cls._missing_) # type: ignore[attr-defined] + self.assertNotIn('extend_enum', source) + + +class EtherTypeMixedMintTests(unittest.TestCase): + """:class:`~pcapkit.const.reg.ethertype.EtherType` is the ruling's mixed + case: ``DEC Unassigned`` and the "Old Xerox Experimental..." row convert, + every other attributed vendor block (a real company's own name for its + own code) keeps minting.""" + + def setUp(self) -> None: + snapshot = snapshot_modules(ISOLATED_PREFIXES) + purge_modules(['pcapkit']) + self.addCleanup(restore_modules, snapshot, ISOLATED_PREFIXES) + + def test_unassigned_rows_do_not_mint(self) -> None: + from pcapkit.const.reg.ethertype import EtherType + + for value, name in ETHERTYPE_UNASSIGNED_PROBES.items(): + with self.subTest(value=hex(value)): + self.assertNotIn(value, EtherType._value2member_map_) # type: ignore[attr-defined] + before = len(EtherType.__members__) + + member = EtherType(value) + + self.assertEqual(member.value, value) + self.assertEqual(member.name, name) + self.assertEqual(before, len(EtherType.__members__)) + self.assertNotIn(value, EtherType._value2member_map_) # type: ignore[attr-defined] + + def test_masked_old_xerox_row_converts_by_source(self) -> None: + """0x0101-0x01FF is unreachable at runtime -- masked by the wider + 0x0000-0x05DC branch that precedes it, a pre-existing ordering issue + (see :data:`ETHERTYPE_UNASSIGNED_PROBES`'s comment) unrelated to this + ruling. Proved by source instead of by calling it.""" + from pcapkit.const.reg.ethertype import EtherType + + source = inspect.getsource(EtherType._missing_) # type: ignore[attr-defined] + self.assertIn(f"cls._unregistered_member(value, '{ETHERTYPE_MASKED_UNASSIGNED_LABEL}')", source) + self.assertNotIn(f"extend_enum(cls, '{ETHERTYPE_MASKED_UNASSIGNED_LABEL}", source) + + def test_attributed_vendor_block_still_mints(self) -> None: + from pcapkit.const.reg.ethertype import EtherType + + value, name = ETHERTYPE_KEPT_PROBE + self.assertNotIn(value, EtherType._value2member_map_) # type: ignore[attr-defined] + before = len(EtherType.__members__) + + member = EtherType(value) + + self.assertEqual(member.value, value) + self.assertEqual(member.name, name) + self.assertEqual(before + 1, len(EtherType.__members__)) + self.assertIn(value, EtherType._value2member_map_) # type: ignore[attr-defined] + self.assertIs(EtherType(value), member) + + +class IPXSocketMixedMintTests(unittest.TestCase): + """:class:`~pcapkit.const.ipx.socket.Socket` is the ruling's other mixed + case: ``Experimental`` and the three "who may claim this pool" allocation- + policy labels convert; ``Registered by Xerox`` -- a real ownership fact -- + keeps minting.""" + + def setUp(self) -> None: + snapshot = snapshot_modules(ISOLATED_PREFIXES) + purge_modules(['pcapkit']) + self.addCleanup(restore_modules, snapshot, ISOLATED_PREFIXES) + + def test_unassigned_rows_do_not_mint(self) -> None: + from pcapkit.const.ipx.socket import Socket + + for value, name in IPX_SOCKET_UNASSIGNED_PROBES.items(): + with self.subTest(value=hex(value)): + self.assertNotIn(value, Socket._value2member_map_) # type: ignore[attr-defined] + before = len(Socket.__members__) + + member = Socket(value) + + self.assertEqual(member.value, value) + self.assertEqual(member.name, name) + self.assertEqual(before, len(Socket.__members__)) + self.assertNotIn(value, Socket._value2member_map_) # type: ignore[attr-defined] + + def test_registered_by_xerox_still_mints(self) -> None: + from pcapkit.const.ipx.socket import Socket + + value, name = IPX_SOCKET_KEPT_PROBE + self.assertNotIn(value, Socket._value2member_map_) # type: ignore[attr-defined] + before = len(Socket.__members__) + + member = Socket(value) + + self.assertEqual(member.value, value) + self.assertEqual(member.name, name) + self.assertEqual(before + 1, len(Socket.__members__)) + self.assertIn(value, Socket._value2member_map_) # type: ignore[attr-defined] + self.assertIs(Socket(value), member) + + if __name__ == '__main__': unittest.main() diff --git a/tests/const/test_const_registry_protocol.py b/tests/const/test_const_registry_protocol.py index e438a0e316..1c5d38f12f 100644 --- a/tests/const/test_const_registry_protocol.py +++ b/tests/const/test_const_registry_protocol.py @@ -861,20 +861,25 @@ def test_hardware_still_bounds_and_resolves_its_unassigned_ranges(self) -> None: Hardware.get(65536) self.assertIs(Hardware.get(65536, 1), Hardware.Ethernet) - def test_transtype_still_mints_its_declared_unassigned_range(self) -> None: - """:class:`~pcapkit.const.reg.transtype.TransType` is the other - shape: its own ``_missing_`` mints permanently via + def test_transtype_no_longer_mints_its_declared_unassigned_range(self) -> None: + """:class:`~pcapkit.const.reg.transtype.TransType` used to be the + other shape: its own ``_missing_`` minted permanently via :func:`~aenum.extend_enum` for ``148..252`` rather than going through - ``_unregistered_member`` -- also unchanged by this tier.""" + ``_unregistered_member``. GitHub issues #775/#847's mint-criterion + ruling converted it: the label is a bare ``Unassigned``, which is a + notation for the reader rather than a name IANA assigned, so it now + matches :class:`~pcapkit.const.arp.hardware.Hardware`'s shape above + instead of standing apart from it.""" from pcapkit.const.reg.transtype import TransType before = len(TransType._member_names_) member = TransType(200) self.assertEqual(member.value, 200) - self.assertEqual(member.name, 'Unassigned_200') - self.assertIn(200, TransType._value2member_map_) - self.assertEqual(before + 1, len(TransType._member_names_)) + self.assertEqual(member.name, 'Unassigned') + self.assertNotIn(200, TransType._value2member_map_) + self.assertEqual(before, len(TransType._member_names_)) + self.assertEqual(TransType(200), TransType.get(200)) with self.assertRaises(ValueError): TransType(9999) diff --git a/tests/corekit/test_fields_numbers_unassigned_enum.py b/tests/corekit/test_fields_numbers_unassigned_enum.py index 33e3ed7dfa..8d4450d776 100644 --- a/tests/corekit/test_fields_numbers_unassigned_enum.py +++ b/tests/corekit/test_fields_numbers_unassigned_enum.py @@ -178,15 +178,21 @@ def test_a_declared_member_still_resolves_to_the_registry_member(self) -> None: self.assertIs(field.unpack(b'\x0a\x0d\x0d\x0a', dict()), BlockType.Section_Header_Block) - def test_a_missing_rule_still_mints_its_own_member(self) -> None: + def test_a_missing_rule_still_takes_precedence_over_the_fallback(self) -> None: """``_missing_`` keeps precedence over the fallback. ``0x0bad0bad`` is in one of the ``Reserved_*`` ranges :meth:`BlockType._missing_ - ` extends, so it has - always resolved -- to a real ``BlockType`` member, named for its range. - The fallback must not shadow that: if it did, a reserved code would come - back nameless and lose the only thing the registry knows about it. + ` covers. Per the + mint/unmint ruling recorded for #775 (``docs/source/conventions.rst``), + ``Reserved`` names a procedure rather than a party, so this range no + longer *mints* a registered ``Reserved_0bad0bad`` member -- it now + returns an unregistered member via ``_unregistered_member``, bearing the + bare label ``Reserved`` and the original value. The fallback must still + not shadow ``_missing_``: if it did, a reserved code would come back + nameless and lose the only thing the registry knows about it. Because + the name alone (``Reserved``) no longer pins the value the way + ``Reserved_0bad0bad`` used to, the value is asserted explicitly too. """ from pcapkit.const.pcapng.block_type import BlockType @@ -196,7 +202,8 @@ def test_a_missing_rule_still_mints_its_own_member(self) -> None: resolved = field.unpack(b'\x0b\xad\x0b\xad', dict()) self.assertIsInstance(resolved, BlockType) - self.assertEqual(resolved.name, 'Reserved_0bad0bad') + self.assertEqual(resolved.name, 'Reserved') + self.assertEqual(int(resolved), 0x0bad0bad) def test_the_registry_own_guard_is_not_weakened(self) -> None: """The change is at the field layer and nowhere else. diff --git a/tests/protocols/misc/test_pcapng_unit.py b/tests/protocols/misc/test_pcapng_unit.py index 158fc0555c..3c5dbd7773 100644 --- a/tests/protocols/misc/test_pcapng_unit.py +++ b/tests/protocols/misc/test_pcapng_unit.py @@ -777,6 +777,15 @@ def test_pcapng_option_readers_cover_block_families_and_guards(self) -> None: UnknownOption) from pcapkit.utilities.exceptions import ProtocolError + # Per the mint/unmint ruling for #775 (``docs/source/conventions.rst``), + # ``Unassigned`` names a procedure rather than a party, so ``FilterType``'s + # ``_missing_`` no longer mints a registered ``Unassigned_0`` member for + # code 0 -- it returns an unregistered member bearing the bare label + # ``Unassigned``. ``FilterType(0)`` is used below wherever the fixtures + # need *some* valid ``FilterType`` value for code 0; this pins that the + # value obtained that way is the one the ruling now produces. + self.assertEqual(FilterType(0).name, 'Unassigned') + pcapng = object.__new__(PCAPNG) pcapng._opt = collections.Counter() @@ -886,7 +895,7 @@ def with_length(schema: object, length: int) -> object: ).timezone, datetime.timezone(datetime.timedelta(hours=2))) self.assertEqual(pcapng._read_option_if_filter( IF_FilterOption(type=OptionType.if_filter, length=4, - code=FilterType.Unassigned_0, filter=b'tcp'), + code=FilterType(0), filter=b'tcp'), options=options, ).expression, b'tcp') self.assertEqual(pcapng._read_option_if_os( @@ -926,7 +935,7 @@ def with_length(schema: object, length: int) -> object: BlockType.Interface_Description_Block) assert_protocol_error('_read_option_if_filter', IF_FilterOption(type=OptionType.if_filter, length=0, - code=FilterType.Unassigned_0, filter=b''), + code=FilterType(0), filter=b''), BlockType.Interface_Description_Block) interface_error_cases = [ ('_read_option_if_description', @@ -960,7 +969,7 @@ def with_length(schema: object, length: int) -> object: True, True), ('_read_option_if_filter', IF_FilterOption(type=OptionType.if_filter, length=4, - code=FilterType.Unassigned_0, filter=b'tcp'), + code=FilterType(0), filter=b'tcp'), True, False), ('_read_option_if_os', IF_OSOption(type=OptionType.if_os, length=2, os='OS'), @@ -1891,6 +1900,15 @@ def test_pcapng_remaining_constructor_branches_and_custom_dispatch(self) -> None UnknownSecrets as SchemaUnknownSecrets) from pcapkit.utilities.exceptions import ProtocolError + # Per the mint/unmint ruling for #775 (``docs/source/conventions.rst``), + # ``Unassigned`` names a procedure rather than a party, so ``FilterType``'s + # ``_missing_`` no longer mints a registered ``Unassigned_0`` member for + # code 0 -- it returns an unregistered member bearing the bare label + # ``Unassigned``. ``FilterType(0)`` is used below wherever the fixtures + # need *some* valid ``FilterType`` value for code 0; this pins that the + # value obtained that way is the one the ruling now produces. + self.assertEqual(FilterType(0).name, 'Unassigned') + pcapng = object.__new__(PCAPNG) pcapng._byte = 'little' pcapng._ctx = None @@ -2046,7 +2064,7 @@ def assert_duplicate(method: str, code: OptionType, block: BlockType, **kwargs: ('_make_option_if_tzone', OptionType.if_tzone, DummyData(timezone=datetime.timezone(datetime.timedelta(hours=3))), 'tzone', 10800), ('_make_option_if_filter', OptionType.if_filter, - DummyData(code=FilterType.Unassigned_0, expression=b'udp'), 'filter', b'udp'), + DummyData(code=FilterType(0), expression=b'udp'), 'filter', b'udp'), ('_make_option_if_os', OptionType.if_os, DummyData(os='data-os'), 'os', 'data-os'), ('_make_option_if_fcslen', OptionType.if_fcslen, DummyData(fcs_length=8), 'fcslen', 8), ('_make_option_if_tsoffset', OptionType.if_tsoffset, DummyData(offset=11), 'tsoffset', 11), diff --git a/tests/vendor/test_ipx_socket_unit.py b/tests/vendor/test_ipx_socket_unit.py index 16b51ce319..f6401cda5f 100644 --- a/tests/vendor/test_ipx_socket_unit.py +++ b/tests/vendor/test_ipx_socket_unit.py @@ -100,9 +100,11 @@ #: Sampled sockets and the member name each is expected to resolve to, at the #: bounds of every range plus the gaps between. The *name* is pinned as well as #: the value because the value alone cannot tell a live range branch from a -#: masked one: every branch of the generated ``_missing_`` returns ``value``, so -#: only the name says which branch ran, and asserting the value alone would pass -#: just as happily with three of the five branches deleted. +#: masked one: every branch of the generated ``_missing_`` returns ``value``, +#: so only the name says which branch ran -- for ``Registered by Xerox``, +#: which still mints, that name still carries the value as a numeric suffix; +#: asserting the value alone would pass just as happily with the range +#: branches deleted or reordered. #: #: Before GitHub issue #841 was fixed, three of these were unreachable -- #: ``(0x0001, 0x0BB8)`` masked ``(0x0020, 0x003F)``, and ``(0x0BB9, 0xFFFF)`` @@ -110,21 +112,29 @@ #: ``0x003F``, ``0x4000``, ``0x4FFF``, ``0x8000``, ``0x8061``, ``0x9094`` and #: ``0xFFFF`` all resolved under the wrong wide range's name. See #: :data:`pcapkit.vendor.ipx.socket.RANGES` for the reordering that fixed it. +#: +#: GitHub issues #775/#847's mint-criterion ruling then converted four of the +#: five ranges -- ``Experimental``, ``Dynamically Assigned Socket Numbers``, +#: ``Statically Assigned Socket Numbers`` and ``Dynamically Assigned`` each +#: name an allocation *policy* for the pool rather than a specific assignment, +#: so they no longer mint and their bare name carries no numeric suffix. +#: ``Registered by Xerox`` is the one that stayed: it states a real ownership +#: fact, not a status placeholder, so it still mints exactly as before. EXPECTED_MISSING_NAMES = { 0x0000: 'Unspecified', # a defined member 0x0001: 'Routing_Information_Packet', # a defined member 0x0004: 'Registered by Xerox_0x0004', - 0x0020: 'Experimental_0x0020', - 0x003F: 'Experimental_0x003F', + 0x0020: 'Experimental', + 0x003F: 'Experimental', 0x0BB8: 'Registered by Xerox_0x0BB8', - 0x0BB9: 'Dynamically Assigned_0x0BB9', - 0x4000: 'Dynamically Assigned Socket Numbers_0x4000', - 0x4FFF: 'Dynamically Assigned Socket Numbers_0x4FFF', - 0x7FFF: 'Dynamically Assigned_0x7FFF', - 0x8000: 'Statically Assigned Socket Numbers_0x8000', - 0x8061: 'Statically Assigned Socket Numbers_0x8061', - 0x9094: 'Statically Assigned Socket Numbers_0x9094', - 0xFFFF: 'Statically Assigned Socket Numbers_0xFFFF', + 0x0BB9: 'Dynamically Assigned', + 0x4000: 'Dynamically Assigned Socket Numbers', + 0x4FFF: 'Dynamically Assigned Socket Numbers', + 0x7FFF: 'Dynamically Assigned', + 0x8000: 'Statically Assigned Socket Numbers', + 0x8061: 'Statically Assigned Socket Numbers', + 0x9094: 'Statically Assigned Socket Numbers', + 0xFFFF: 'Statically Assigned Socket Numbers', } @@ -267,11 +277,13 @@ def test_previously_shadowed_ranges_are_reachable(self) -> None: # 'Registered by Xerox_0x0030', 0x4080 and 0x8100 both as # 'Dynamically Assigned_0x...'. Pinned separately from # test_unlisted_sockets_still_resolve so the regression this issue - # describes has a test that names it. + # describes has a test that names it. Bare names, not the numeric- + # suffixed ones #841 pinned: GitHub issues #775/#847 converted all + # three of these ranges after #841 landed. for value, name in ( - (0x0030, 'Experimental_0x0030'), - (0x4080, 'Dynamically Assigned Socket Numbers_0x4080'), - (0x8100, 'Statically Assigned Socket Numbers_0x8100'), + (0x0030, 'Experimental'), + (0x4080, 'Dynamically Assigned Socket Numbers'), + (0x8100, 'Statically Assigned Socket Numbers'), ): with self.subTest(socket=f'0x{value:04X}'): member = self.const_module.Socket(value)