././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5784907 django_macaddress-1.9.0/0000755000175100017510000000000015067044147014627 5ustar00runnerrunner././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/LICENSE0000644000175100017510000000277115067044133015636 0ustar00runnerrunnerCopyright (c) 2011 Ryan Nowakowski All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/MANIFEST.in0000644000175100017510000000004415067044133016356 0ustar00runnerrunnerinclude LICENSE include README.rst ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5784907 django_macaddress-1.9.0/PKG-INFO0000644000175100017510000001225415067044147015730 0ustar00runnerrunnerMetadata-Version: 2.4 Name: django-macaddress Version: 1.9.0 Summary: MAC address model and form fields for Django apps. Home-page: http://github.com/tubaman/django-macaddress Author: Ryan Nowakowski Author-email: tubaman@fattuba.com Maintainer: Arun Karunagath Maintainer-email: the1.arun@gmail.com License: BSD Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Topic :: Internet :: WWW/HTTP License-File: LICENSE Requires-Dist: netaddr Dynamic: author Dynamic: author-email Dynamic: classifier Dynamic: description Dynamic: home-page Dynamic: license Dynamic: license-file Dynamic: maintainer Dynamic: maintainer-email Dynamic: requires-dist Dynamic: summary django-macaddress ================== .. image:: https://travis-ci.org/django-macaddress/django-macaddress.svg?branch=master :alt: Build Status :target: https://travis-ci.org/django-macaddress/django-macaddress .. image:: https://img.shields.io/pypi/v/django-macaddress.svg :target: https://crate.io/packages/django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Patches welcome: http://github.com/django-macaddress/django-macaddress Release Notes: ************** For release info: https://github.com/django-macaddress/django-macaddress/releases Getting Started *************** settings.MACADDRESS_DEFAULT_DIALECT ----------------------------------- To specify a default dialect for presentation (and storage, see below), specify:: settings.MACADDRESS_DEFAULT_DIALECT = 'module.dialect_class' where the specified value is a string composed of a parent python module name and the child dialect class name. For example:: settings.MACADDRESS_DEFAULT_DIALECT = 'netaddr.mac_eui48' PS: old default of macaddress.mac_linux (uppercase and divided by ':' ) will be used by default. If the custom dialect is defined in a package module, you will need to define the class in or import into the package's ``__init__.py``. ``default_dialect`` and ``format_mac`` -------------------------------------- To get the default dialect for your project, import and call the ``default_dialect`` function:: >>> from macaddress import default_dialect >>> dialect = default_dialect() This function may, optionally, be called with an ``netaddr.EUI`` class instance as its argument. If no default is defined in ``settings``, it will return the dialect of the provided ``EUI`` object. The ``format_mac`` function takes an ``EUI`` instance and a dialect class (``netaddr.mac_eui48`` or a subclass) as its arguments. The dialect class may be specified as a string in the same manner as ``settings.MACADDRESS_DEFAULT_DIALECT``:: >>> from netaddr import EUI, mac_bare >>> from macaddress import format_mac >>> mac = EUI('00:12:3c:37:64:8f') >>> format_mac(mac, mac_bare) '00123C37648F' >>> format_mac(mac, 'netaddr.mac_cisco') '0012.3c37.648f' MACAddressField (ModelField) ---------------------------- This is an example model using MACAddressField:: from macaddress.fields import MACAddressField class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(null=True, blank=True) ... The default behavior is to store the MAC Address in the database is a BigInteger. If you would, rather, store the value as a string (to, for instance, facilitate sub-string searches), you can specify ``integer=False`` and the value will be stored as a string:: class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(blank=True, integer=False) ... If you want to set ``unique=True`` on a MACAddressField that is stored as a string, you will need to set ``null=True`` and create custom ``clean_`` methods on your ``forms.ModelForm`` class for each MACAddressField that return ``None`` when the value provided is an ``''`` (empty string):: from .models import Computer class ComputerForm(forms.ModelForm): class Meta: model = Computer def clean_eth0(self): return self.cleaned_data['eth0'] or None You should avoid changing the value of ``integer`` after running ``managy.py syncdb``, unless you are using a schema migration solution like South or Django's built-in migrations. To Do ***** + Add greater support for partial string queries when storing MACs as strings in the database. + Add custom validator to check for duplicate MACs when mixing string and integer storage types. + Add deprecation warning and timeline for changeover to default string storage. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/README.rst0000644000175100017510000000770515067044133016322 0ustar00runnerrunnerdjango-macaddress ================== .. image:: https://travis-ci.org/django-macaddress/django-macaddress.svg?branch=master :alt: Build Status :target: https://travis-ci.org/django-macaddress/django-macaddress .. image:: https://img.shields.io/pypi/v/django-macaddress.svg :target: https://crate.io/packages/django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Patches welcome: http://github.com/django-macaddress/django-macaddress Release Notes: ************** For release info: https://github.com/django-macaddress/django-macaddress/releases Getting Started *************** settings.MACADDRESS_DEFAULT_DIALECT ----------------------------------- To specify a default dialect for presentation (and storage, see below), specify:: settings.MACADDRESS_DEFAULT_DIALECT = 'module.dialect_class' where the specified value is a string composed of a parent python module name and the child dialect class name. For example:: settings.MACADDRESS_DEFAULT_DIALECT = 'netaddr.mac_eui48' PS: old default of macaddress.mac_linux (uppercase and divided by ':' ) will be used by default. If the custom dialect is defined in a package module, you will need to define the class in or import into the package's ``__init__.py``. ``default_dialect`` and ``format_mac`` -------------------------------------- To get the default dialect for your project, import and call the ``default_dialect`` function:: >>> from macaddress import default_dialect >>> dialect = default_dialect() This function may, optionally, be called with an ``netaddr.EUI`` class instance as its argument. If no default is defined in ``settings``, it will return the dialect of the provided ``EUI`` object. The ``format_mac`` function takes an ``EUI`` instance and a dialect class (``netaddr.mac_eui48`` or a subclass) as its arguments. The dialect class may be specified as a string in the same manner as ``settings.MACADDRESS_DEFAULT_DIALECT``:: >>> from netaddr import EUI, mac_bare >>> from macaddress import format_mac >>> mac = EUI('00:12:3c:37:64:8f') >>> format_mac(mac, mac_bare) '00123C37648F' >>> format_mac(mac, 'netaddr.mac_cisco') '0012.3c37.648f' MACAddressField (ModelField) ---------------------------- This is an example model using MACAddressField:: from macaddress.fields import MACAddressField class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(null=True, blank=True) ... The default behavior is to store the MAC Address in the database is a BigInteger. If you would, rather, store the value as a string (to, for instance, facilitate sub-string searches), you can specify ``integer=False`` and the value will be stored as a string:: class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(blank=True, integer=False) ... If you want to set ``unique=True`` on a MACAddressField that is stored as a string, you will need to set ``null=True`` and create custom ``clean_`` methods on your ``forms.ModelForm`` class for each MACAddressField that return ``None`` when the value provided is an ``''`` (empty string):: from .models import Computer class ComputerForm(forms.ModelForm): class Meta: model = Computer def clean_eth0(self): return self.cleaned_data['eth0'] or None You should avoid changing the value of ``integer`` after running ``managy.py syncdb``, unless you are using a schema migration solution like South or Django's built-in migrations. To Do ***** + Add greater support for partial string queries when storing MACs as strings in the database. + Add custom validator to check for duplicate MACs when mixing string and integer storage types. + Add deprecation warning and timeline for changeover to default string storage. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5784907 django_macaddress-1.9.0/django_macaddress.egg-info/0000755000175100017510000000000015067044147021751 5ustar00runnerrunner././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266918.0 django_macaddress-1.9.0/django_macaddress.egg-info/PKG-INFO0000644000175100017510000001225415067044146023051 0ustar00runnerrunnerMetadata-Version: 2.4 Name: django-macaddress Version: 1.9.0 Summary: MAC address model and form fields for Django apps. Home-page: http://github.com/tubaman/django-macaddress Author: Ryan Nowakowski Author-email: tubaman@fattuba.com Maintainer: Arun Karunagath Maintainer-email: the1.arun@gmail.com License: BSD Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Topic :: Internet :: WWW/HTTP License-File: LICENSE Requires-Dist: netaddr Dynamic: author Dynamic: author-email Dynamic: classifier Dynamic: description Dynamic: home-page Dynamic: license Dynamic: license-file Dynamic: maintainer Dynamic: maintainer-email Dynamic: requires-dist Dynamic: summary django-macaddress ================== .. image:: https://travis-ci.org/django-macaddress/django-macaddress.svg?branch=master :alt: Build Status :target: https://travis-ci.org/django-macaddress/django-macaddress .. image:: https://img.shields.io/pypi/v/django-macaddress.svg :target: https://crate.io/packages/django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Patches welcome: http://github.com/django-macaddress/django-macaddress Release Notes: ************** For release info: https://github.com/django-macaddress/django-macaddress/releases Getting Started *************** settings.MACADDRESS_DEFAULT_DIALECT ----------------------------------- To specify a default dialect for presentation (and storage, see below), specify:: settings.MACADDRESS_DEFAULT_DIALECT = 'module.dialect_class' where the specified value is a string composed of a parent python module name and the child dialect class name. For example:: settings.MACADDRESS_DEFAULT_DIALECT = 'netaddr.mac_eui48' PS: old default of macaddress.mac_linux (uppercase and divided by ':' ) will be used by default. If the custom dialect is defined in a package module, you will need to define the class in or import into the package's ``__init__.py``. ``default_dialect`` and ``format_mac`` -------------------------------------- To get the default dialect for your project, import and call the ``default_dialect`` function:: >>> from macaddress import default_dialect >>> dialect = default_dialect() This function may, optionally, be called with an ``netaddr.EUI`` class instance as its argument. If no default is defined in ``settings``, it will return the dialect of the provided ``EUI`` object. The ``format_mac`` function takes an ``EUI`` instance and a dialect class (``netaddr.mac_eui48`` or a subclass) as its arguments. The dialect class may be specified as a string in the same manner as ``settings.MACADDRESS_DEFAULT_DIALECT``:: >>> from netaddr import EUI, mac_bare >>> from macaddress import format_mac >>> mac = EUI('00:12:3c:37:64:8f') >>> format_mac(mac, mac_bare) '00123C37648F' >>> format_mac(mac, 'netaddr.mac_cisco') '0012.3c37.648f' MACAddressField (ModelField) ---------------------------- This is an example model using MACAddressField:: from macaddress.fields import MACAddressField class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(null=True, blank=True) ... The default behavior is to store the MAC Address in the database is a BigInteger. If you would, rather, store the value as a string (to, for instance, facilitate sub-string searches), you can specify ``integer=False`` and the value will be stored as a string:: class Computer(models.Model): name = models.CharField(max_length=32) eth0 = MACAddressField(blank=True, integer=False) ... If you want to set ``unique=True`` on a MACAddressField that is stored as a string, you will need to set ``null=True`` and create custom ``clean_`` methods on your ``forms.ModelForm`` class for each MACAddressField that return ``None`` when the value provided is an ``''`` (empty string):: from .models import Computer class ComputerForm(forms.ModelForm): class Meta: model = Computer def clean_eth0(self): return self.cleaned_data['eth0'] or None You should avoid changing the value of ``integer`` after running ``managy.py syncdb``, unless you are using a schema migration solution like South or Django's built-in migrations. To Do ***** + Add greater support for partial string queries when storing MACs as strings in the database. + Add custom validator to check for duplicate MACs when mixing string and integer storage types. + Add deprecation warning and timeline for changeover to default string storage. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266918.0 django_macaddress-1.9.0/django_macaddress.egg-info/SOURCES.txt0000644000175100017510000000066415067044146023642 0ustar00runnerrunnerLICENSE MANIFEST.in README.rst pyproject.toml setup.py django_macaddress.egg-info/PKG-INFO django_macaddress.egg-info/SOURCES.txt django_macaddress.egg-info/dependency_links.txt django_macaddress.egg-info/requires.txt django_macaddress.egg-info/top_level.txt macaddress/__init__.py macaddress/fields.py macaddress/formfields.py macaddress/models.py macaddress/tests/__init__.py macaddress/tests/models.py macaddress/tests/test_fields.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266918.0 django_macaddress-1.9.0/django_macaddress.egg-info/dependency_links.txt0000644000175100017510000000000115067044146026016 0ustar00runnerrunner ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266918.0 django_macaddress-1.9.0/django_macaddress.egg-info/requires.txt0000644000175100017510000000001015067044146024337 0ustar00runnerrunnernetaddr ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266918.0 django_macaddress-1.9.0/django_macaddress.egg-info/top_level.txt0000644000175100017510000000001315067044146024474 0ustar00runnerrunnermacaddress ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5774908 django_macaddress-1.9.0/macaddress/0000755000175100017510000000000015067044147016735 5ustar00runnerrunner././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/__init__.py0000644000175100017510000000465615067044133021054 0ustar00runnerrunnerimport importlib import warnings from importlib.metadata import PackageNotFoundError, version from django.conf import settings from netaddr import mac_eui48, mac_unix class mac_linux(mac_unix): """MAC format with zero-padded all upper-case hex and colon separated""" word_fmt = "%.2X" def default_dialect(eui_obj=None): # Check to see if a default dialect class has been specified in settings, # using 'module.dialect_cls' string and use importlib and getattr to retrieve dialect class. # 'module' is the module and 'dialect_cls' is the class name of the custom dialect. # The dialect must either be defined or imported by the module's __init__.py if the module is a package. from .fields import MACAddressField # Remove import at v1.4 if hasattr(settings, "MACADDRESS_DEFAULT_DIALECT") and not MACAddressField.dialect: module, dialect_cls = settings.MACADDRESS_DEFAULT_DIALECT.split(".") dialect = getattr(importlib.import_module(module), dialect_cls, mac_linux) return dialect else: if MACAddressField.dialect: # Remove this "if" statement at v1.4 warnings.warn( "The set_dialect class method on MACAddressField has been deprecated, in favor of the default_dialect " "utility function and settings.MACADDRESS_DEFAULT_DIALECT. See macaddress.__init__.py source or the " "project README for more information.", DeprecationWarning, ) return MACAddressField.dialect if eui_obj: return eui_obj.dialect else: return mac_linux def format_mac(eui_obj, dialect): # Format a EUI instance as a string using the supplied dialect class, allowing custom string classes by # passing directly or as a string, a la 'module.dialect_cls', where 'module' is the module and 'dialect_cls' # is the class name of the custom dialect. The dialect must either be defined or imported by the module's # __init__.py if the module is a package. if not isinstance(dialect, mac_eui48) and isinstance(dialect, str): module, dialect_cls = dialect.split(".") dialect = getattr(importlib.import_module(module), dialect_cls) eui_obj.dialect = dialect return str(eui_obj) try: __version__ = version("django-macaddress") except PackageNotFoundError: __version__ = "Please install this project with setup.py" VERSION = __version__ # synonym ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/fields.py0000644000175100017510000000703515067044133020555 0ustar00runnerrunnerimport warnings from django.core.exceptions import ValidationError from django.db import models from netaddr import EUI, AddrFormatError from . import default_dialect from .formfields import MACAddressField as MACAddressFormField class MACAddressField(models.Field): description = "A MAC address validated by netaddr.EUI" empty_strings_allowed = False dialect = None def __init__(self, *args, **kwargs): self.integer = kwargs.pop("integer", True) if ( not self.integer ): # If storing MAC address as string, set max_length to default (17) or use supplied kwarg value. kwargs["max_length"] = kwargs.get("max_length", 17) super().__init__(*args, **kwargs) def deconstruct(self): """Django 1.7 migrations require this method https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#field-deconstruction """ name, path, args, kwargs = super().deconstruct() kwargs["integer"] = self.integer return name, path, args, kwargs @classmethod def set_dialect(cls, new_dialect_clazz): """Setting dialect for EUI (MAC addresses) globally to this Field class. Class new_dialect_clazz should (finally) extend netaddr.strategy.eui48.mac_eui48. """ warnings.warn( "The set_dialect method has been deprecated, in favor of the default_dialect utility function and " " settings.MACADDRESS_DEFAULT_DIALECT. See macaddress.__init__.py source or the project README for " "more information.", DeprecationWarning, ) cls.dialect = new_dialect_clazz def get_prep_value(self, value): if value is None: return None if not isinstance(value, EUI): value = self.to_python(value) if self.integer: return int(value) return str(value) value.dialect = default_dialect(self) if self.integer: return int(value) return str(value) def get_internal_type(self): if self.integer: return "BigIntegerField" return "CharField" def from_db_value(self, value, expression, connection): return self.to_python(value) def to_python(self, value): if value is None: return value if isinstance(value, EUI): value.dialect = default_dialect(value) return value try: return EUI(value, version=48, dialect=default_dialect()) except (TypeError, ValueError, AddrFormatError): raise ValidationError("This value must be a valid MAC address.") def formfield(self, **kwargs): defaults = {"form_class": MACAddressFormField} defaults.update(kwargs) return super().formfield(**defaults) def get_prep_lookup(self, lookup_type, value): # data is stored internally as integer so searching as string # yield 0 result. for example: useful for search in admin. if lookup_type in ("exact", "iexact", "icontains", "icontains"): try: return self.get_prep_value(value) except AddrFormatError: return None elif lookup_type in ("in"): try: macs = [] for mac in value: macs += [self.get_prep_value(mac)] return macs except AddrFormatError: return None else: raise TypeError(f"Lookup type {lookup_type!r} not supported.") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/formfields.py0000644000175100017510000000146515067044133021442 0ustar00runnerrunnerfrom django.core.validators import EMPTY_VALUES from django.forms import Field from django.forms.utils import ValidationError from django.utils.translation import gettext_lazy as _ from netaddr import EUI, AddrFormatError class MACAddressField(Field): default_error_messages = { "invalid": _("Enter a valid MAC Address."), } def clean(self, value): """ Validates that EUI() can be called on the input. Returns the result of EUI(). Returns None for empty values. """ value = super().clean(value) if value in EMPTY_VALUES: return None try: value = EUI(str(value), version=48) except (ValueError, TypeError, AddrFormatError): raise ValidationError(self.error_messages["invalid"]) return value ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/models.py0000644000175100017510000000004615067044133020565 0ustar00runnerrunner# This file intentionally left blank. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5774908 django_macaddress-1.9.0/macaddress/tests/0000755000175100017510000000000015067044147020077 5ustar00runnerrunner././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/tests/__init__.py0000644000175100017510000000000015067044133022171 0ustar00runnerrunner././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/tests/models.py0000644000175100017510000000033715067044133021732 0ustar00runnerrunner""" A model for testing """ from django.db import models from macaddress.fields import MACAddressField class NetworkThingy(models.Model): mac = MACAddressField() def __str__(self): return f"{self.mac}" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/macaddress/tests/test_fields.py0000644000175100017510000000147115067044133022754 0ustar00runnerrunnerimport pytest from django.core.exceptions import ValidationError from django.db import transaction from django.test import TestCase from .models import NetworkThingy class MACAddressFieldTestCase(TestCase): def test_insert_valid_macaddress(self): mac_example = "00:11:22:33:44:aa" x = NetworkThingy(mac=mac_example) x.save() qm = NetworkThingy.objects assert x.mac == mac_example assert qm.get(mac=mac_example).mac == mac_example assert qm.all().count() == 1 def test_insert_invalid_macaddress(self): invalid_mac = "XX" with transaction.atomic(): x = NetworkThingy() x.mac = invalid_mac with pytest.raises(ValidationError): x.save() assert NetworkThingy.objects.all().count() == 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/pyproject.toml0000644000175100017510000000236215067044133017541 0ustar00runnerrunner[tool.ruff] target-version = 'py311' line-length = 120 [tool.ruff.lint] # See complete list : https://docs.astral.sh/ruff/rules/ select = [ "F", # pyflakes "E", # pycodestyle errors "W", # pycodestyle warnings "I", # isort "YTT", # flake8-2020 "B006", # flake8-bugbear-mutable-argument-default "B008", # flake8-bugbear-function-call-in-default-argument (B008) "A", # flake8-builtins "C4", # flake8-comprehensions "T10", # flake8-debugger "DJ", # flake8-django "EXE", # flake8-executable "FA", # flake8-future-annotations "ISC", # flake8-implicit-str-concat "ICN", # flake8-import-conventions "INP", # flake8-no-pep420 "PIE", # flake8-pie "T20", # flake8-print "PYI", # flake8-pyi "PT", # flake8-pytest-style "SLOT", # flake8-slots "SIM", # flake8-simplify "TID", # flake8-tidy-imports "Q", # flake8-quotes "RSE", # flake8-raise "SLF", # flake8-self "TCH", # flake8-type-checking "INT", # flake8-gettext "FLY", # flynt "NPY", # numpy-specific rules "AIR", # airflow "PERF", # perflint "UP", # pyupgrade "FURB", # refurb "PD", # pandas-vet ] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1759266918.5784907 django_macaddress-1.9.0/setup.cfg0000644000175100017510000000004615067044147016450 0ustar00runnerrunner[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1759266907.0 django_macaddress-1.9.0/setup.py0000644000175100017510000000254115067044133016336 0ustar00runnerrunnerimport os from setuptools import setup version = "1.9.0" def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name="django-macaddress", version=version, url="http://github.com/tubaman/django-macaddress", license="BSD", description="MAC address model and form fields for Django apps.", long_description=read("README.rst"), author="Ryan Nowakowski", author_email="tubaman@fattuba.com", maintainer="Arun Karunagath", maintainer_email="the1.arun@gmail.com", packages=["macaddress", "macaddress.tests"], install_requires=["netaddr"], tests_require=["Django"], test_suite="runtests.runtests", classifiers=[ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Topic :: Internet :: WWW/HTTP", ], )