From febe78990245251d6419639b241129ff2c21ac40 Mon Sep 17 00:00:00 2001 From: liubo Date: Tue, 14 Nov 2023 10:58:26 +0800 Subject: [PATCH] Add hash capabilities to OUI Signed-off-by: liubo (cherry picked from commit 86d780326749cf2d1ddf4eadbec8623e93312076) --- 0001-Add-hash-capabilities-to-OUI-225.patch | 47 +++++++++++++++++++++ python-netaddr.spec | 6 ++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 0001-Add-hash-capabilities-to-OUI-225.patch diff --git a/0001-Add-hash-capabilities-to-OUI-225.patch b/0001-Add-hash-capabilities-to-OUI-225.patch new file mode 100644 index 0000000..e61157f --- /dev/null +++ b/0001-Add-hash-capabilities-to-OUI-225.patch @@ -0,0 +1,47 @@ +From b6c4203f85dba18074971208c0602c5bada90e8b Mon Sep 17 00:00:00 2001 +From: amitmi704 <36094800+amitmi704@users.noreply.github.com> +Date: Sun, 7 Feb 2021 18:54:27 -0600 +Subject: [PATCH] Add hash capabilities to OUI (#225) + +Closes #224 +--- + netaddr/eui/__init__.py | 3 +++ + netaddr/tests/eui/test_eui.py | 8 ++++++++ + 2 files changed, 11 insertions(+) + +diff --git a/netaddr/eui/__init__.py b/netaddr/eui/__init__.py +index 5639676..07bbdc3 100644 +--- a/netaddr/eui/__init__.py ++++ b/netaddr/eui/__init__.py +@@ -100,6 +100,9 @@ class OUI(BaseIdentifier): + else: + raise NotRegisteredError('OUI %r not registered!' % (oui,)) + ++ def __hash__(self): ++ return hash(self._value) ++ + def __eq__(self, other): + if not isinstance(other, OUI): + try: +diff --git a/netaddr/tests/eui/test_eui.py b/netaddr/tests/eui/test_eui.py +index 645a518..c17d0ce 100644 +--- a/netaddr/tests/eui/test_eui.py ++++ b/netaddr/tests/eui/test_eui.py +@@ -186,6 +186,14 @@ def test_oui_constructor(): + assert oui.reg_count == 3 + + ++def test_oui_hash(): ++ oui0 = OUI(0) ++ oui1 = OUI(1) ++ oui_dict = {oui0: None, oui1: None} ++ ++ assert list(oui_dict.keys()) == [OUI(0), OUI(1)] ++ ++ + def test_eui_iab(): + mac = EUI('00-50-C2-00-0F-01') + assert mac.is_iab() +-- +2.42.0.windows.2 + diff --git a/python-netaddr.spec b/python-netaddr.spec index 640d227..bec0f04 100644 --- a/python-netaddr.spec +++ b/python-netaddr.spec @@ -1,6 +1,6 @@ Name: python-netaddr Version: 0.8.0 -Release: 6 +Release: 7 Summary: A pure Python network address representation and manipulation library License: BSD-3-Clause @@ -10,6 +10,7 @@ Source0: https://pypi.python.org/packages/source/n/netaddr/netaddr-%{vers Patch9000: elimate-ROC-in-python-netaddr.patch Patch9001: disable-test-oui-information.patch Patch9002: 0001-Fix-for-is_loopback-behaviour-issue-222-223.patch +Patch9003: 0001-Add-hash-capabilities-to-OUI-225.patch BuildArch: noarch BuildRequires: python3-devel python3-setuptools python3-sphinx python3-pytest @@ -58,6 +59,9 @@ py.test-%{python3_version} %{_bindir}/netaddr %changelog +* Tue Nov 14 2023 liubo - 0.8.0-7 +- Add hash capabilities to OUI + * Tue Jun 13 2023 zhangpan - 0.8.0-6 - delete taboo words