django-macaddress-1.0.1/0000775000175000017500000000000012057241566016631 5ustar rnowakowrnowakow00000000000000django-macaddress-1.0.1/README.rst0000664000175000017500000000034712057241270020314 0ustar rnowakowrnowakow00000000000000django-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/tubaman/django-macaddress django-macaddress-1.0.1/setup.cfg0000664000175000017500000000007312057241566020452 0ustar rnowakowrnowakow00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 django-macaddress-1.0.1/django_macaddress.egg-info/0000775000175000017500000000000012057241566023753 5ustar rnowakowrnowakow00000000000000django-macaddress-1.0.1/django_macaddress.egg-info/SOURCES.txt0000664000175000017500000000051512057241566025640 0ustar rnowakowrnowakow00000000000000LICENSE MANIFEST.in README.rst 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.pydjango-macaddress-1.0.1/django_macaddress.egg-info/dependency_links.txt0000664000175000017500000000000112057241566030021 0ustar rnowakowrnowakow00000000000000 django-macaddress-1.0.1/django_macaddress.egg-info/PKG-INFO0000664000175000017500000000157412057241566025057 0ustar rnowakowrnowakow00000000000000Metadata-Version: 1.1 Name: django-macaddress Version: 1.0.1 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 License: BSD Description: 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/tubaman/django-macaddress Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP django-macaddress-1.0.1/django_macaddress.egg-info/top_level.txt0000664000175000017500000000001312057241566026477 0ustar rnowakowrnowakow00000000000000macaddress django-macaddress-1.0.1/django_macaddress.egg-info/requires.txt0000664000175000017500000000000712057241566026350 0ustar rnowakowrnowakow00000000000000netaddrdjango-macaddress-1.0.1/MANIFEST.in0000664000175000017500000000004412057241270020355 0ustar rnowakowrnowakow00000000000000include LICENSE include README.rst django-macaddress-1.0.1/PKG-INFO0000664000175000017500000000157412057241566017735 0ustar rnowakowrnowakow00000000000000Metadata-Version: 1.1 Name: django-macaddress Version: 1.0.1 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 License: BSD Description: 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/tubaman/django-macaddress Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP django-macaddress-1.0.1/LICENSE0000664000175000017500000000277112057241270017635 0ustar rnowakowrnowakow00000000000000Copyright (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. django-macaddress-1.0.1/setup.py0000664000175000017500000000160012057241423020330 0ustar rnowakowrnowakow00000000000000import os from setuptools import setup, find_packages def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name = "django-macaddress", version = "1.0.1", 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', packages = ['macaddress'], install_requires = ['netaddr'], tests_require = ['django'], classifiers = [ 'Development Status :: 4 - Beta', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Internet :: WWW/HTTP', ] ) django-macaddress-1.0.1/macaddress/0000775000175000017500000000000012057241566020737 5ustar rnowakowrnowakow00000000000000django-macaddress-1.0.1/macaddress/models.py0000664000175000017500000000004612057241270022564 0ustar rnowakowrnowakow00000000000000# This file intentionally left blank. django-macaddress-1.0.1/macaddress/fields.py0000664000175000017500000000333212057241270022550 0ustar rnowakowrnowakow00000000000000from django.core.exceptions import ValidationError from django.db import models from netaddr import EUI, AddrFormatError, mac_unix from formfields import MACAddressField as MACAddressFormField # monkey patch EUI to work around https://github.com/drkjam/netaddr/issues/21 # we need this if we use unique=True def _eui_deepcopy(obj, memo=None): from copy import copy return copy(obj) EUI.__deepcopy__ = _eui_deepcopy class mac_linux(mac_unix): """MAC format with zero-padded all upper-case hex and colon separated""" word_fmt = '%.2X' class MACAddressField(models.Field): description = "A MAC address validated by netaddr.EUI" empty_strings_allowed = False __metaclass__ = models.SubfieldBase def get_prep_value(self, value): if value is None: return None if not isinstance(value, EUI): return int(EUI(value, dialect=mac_linux)) return int(value) def get_internal_type(self): return "BigIntegerField" def to_python(self, value): if value is None: return value if isinstance(value, EUI): value.dialect = mac_linux return value try: return EUI(value, dialect=mac_linux) 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(MACAddressField, self).formfield(**defaults) try: from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^macaddress\.fields\.MACAddressField"]) except ImportError: pass django-macaddress-1.0.1/macaddress/__init__.py0000664000175000017500000000000012057241270023026 0ustar rnowakowrnowakow00000000000000django-macaddress-1.0.1/macaddress/formfields.py0000664000175000017500000000134012057241270023431 0ustar rnowakowrnowakow00000000000000from django.forms import Field, util from django.forms.fields import EMPTY_VALUES 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(MACAddressField, self).clean(value) if value in EMPTY_VALUES: return None try: value = EUI(str(value)) except (ValueError, TypeError, AddrFormatError): raise util.ValidationError(self.error_messages['invalid']) return value