Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pcapkit/const/ipx/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

"""

from aenum import IntEnum, extend_enum
from aenum import IntEnum

from pcapkit.corekit.enum import EnumRegistry

Expand Down Expand Up @@ -80,7 +80,7 @@ def _missing_(cls, value: 'int') -> 'Socket':
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)
return cls._unregistered_member(value, 'Registered by Xerox_0x%s' % hex(value)[2:].upper().zfill(4))
if 0x4000 <= value <= 0x4FFF:
#: Dynamically Assigned Socket Numbers
return cls._unregistered_member(value, 'Dynamically Assigned Socket Numbers')
Expand Down
106 changes: 53 additions & 53 deletions pcapkit/const/reg/ethertype.py

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions pcapkit/corekit/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,17 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self':

It never mints while resolving ``default``; ``key`` may still mint
through a ``_missing_`` that GitHub issue #775's ruling deliberately
kept minting, on three registries (``EtherType``, ``Socket``,
``CGAType``). Registering a member any other way is
:meth:`register`'s job and nobody else's, which is the ruling #775
exists to carry out: *"so that we dont create registered enums out
of unrecognised/unregistered values, unless user/caller explicitly
kept minting, on one registry (``CGAType``) -- the ruling's final
round converted the other two it originally held out,
``EtherType`` and ``Socket``, so they no longer mint on any path
either. Registering a member any other way is :meth:`register`'s
job and nobody else's, which is the ruling #775 exists to carry
out: *"so that we dont create registered enums out of
unrecognised/unregistered values, unless user/caller explicitly
created them"*. A value inside a registry's declared-but-unassigned
range still resolves, through that registry's own ``_missing_`` and
:meth:`_unregistered_member`, to a member that is deliberately
absent from the lookup tables -- true outside the three registries
absent from the lookup tables -- true outside the one registry
named above, where such a value instead lands in *both* tables,
exactly as :meth:`register` would leave it -- for a non-``str`` key;
the ``str`` case is qualified below. Both describe ``key`` resolution
Expand Down Expand Up @@ -309,15 +311,16 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self':
:class:`~pcapkit.const.reg.apptype.udp.UDP`,
:class:`~pcapkit.const.reg.apptype.sctp.SCTP` and
:class:`~pcapkit.const.reg.apptype.dccp.DCCP`) no longer mint
on any path, so no live witness exists in this tree today. The
registries that still mint directly via
:func:`~aenum.extend_enum` --
:class:`~pcapkit.const.ipx.socket.Socket`,
:class:`~pcapkit.const.mh.cga_type.CGAType` and
:class:`~pcapkit.const.reg.ethertype.EtherType` -- are all
:class:`int`-valued, so a ``str`` name could not reach their mint
branches even if this restriction did not exist; they are not
exceptions to it, just not reachable by it. This is about a future
on any path, so no live witness exists in this tree today. The one
registry that still mints directly via :func:`~aenum.extend_enum`,
:class:`~pcapkit.const.mh.cga_type.CGAType`, is
:class:`int`-valued, so a ``str`` name could not reach its mint
branch even if this restriction did not exist; it is not an
exception to it, just not reachable by it. GitHub issue #775's final
round converted the other two that used to share this footnote,
:class:`~pcapkit.const.ipx.socket.Socket` and
:class:`~pcapkit.const.reg.ethertype.EtherType`, so ``CGAType`` is
now the only one left. This is about a future
``str``-valued registry (or a present one whose ``_missing_``
someday changes) reaching this base with a minting ``_missing_`` of
its own, which the restriction below is written to stay correct
Expand Down
12 changes: 8 additions & 4 deletions pcapkit/vendor/ipx/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,13 @@

#: 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.
#: assigned protocol. The owner's original ruling on #775/#847 held
#: ``Registered by Xerox`` out of this set as a real ownership fact rather
#: than a placeholder. #775's final round converts it too, so this set no
#: longer decides *whether* a range registers -- only *how its name is
#: spelled*: these four keep the bare label with no hex suffix, since the
#: label itself already says nothing was assigned, while ``Registered by
#: Xerox`` keeps the hex-suffixed name it always rendered.
UNASSIGNED_RANGE_NAMES = frozenset({
'Experimental',
'Dynamically Assigned Socket Numbers',
Expand Down Expand Up @@ -319,7 +323,7 @@ def process(self, data: 'dict[int, tuple[str, str]]') -> 'tuple[list[str], list[
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)")
miss.append(f" return cls._unregistered_member(value, '{name}_0x%s' % hex(value)[2:].upper().zfill(4))")
return enum, miss


Expand Down
18 changes: 11 additions & 7 deletions pcapkit/vendor/reg/ethertype.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ class EtherType(Vendor):
#: 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.
#: outright -- rather than a proprietary protocol's real name. The owner's
#: original ruling on #775/#847 held these two out as the only rows to
#: convert to :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_
#: member`, on the theory that a proprietary protocol's company name IS
#: the final concrete name for every other row. #775's final round
#: converts every row alike, so this set no longer decides *whether* a
#: row registers -- only *how its name is spelled*: these two keep the
#: bare label with no hex suffix, since the label itself already says
#: nothing was assigned, while every other row keeps the hex-suffixed
#: name it always rendered.
UNASSIGNED_ROW_NAMES = frozenset({
'DEC Unassigned',
'Old Xerox Experimental values. Invalid as an Ethertype since 1983.',
Expand Down Expand Up @@ -157,7 +161,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]':
if name in self.UNASSIGNED_ROW_NAMES:
block.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}')")
else:
block.append(f" return extend_enum(cls, '{self.safe_name(name)}_0x%s' % hex(value)[2:].upper().zfill(4), value)") # pylint: disable=line-too-long
block.append(f" return cls._unregistered_member(value, '{self.safe_name(name)}_0x%s' % hex(value)[2:].upper().zfill(4))") # pylint: disable=line-too-long
self._insert_range(ranges, (int(start, base=16), int(stop, base=16), block))

miss = [line for _, _, block in ranges for line in block] # type: list[str]
Expand Down
Loading
Loading