Did I find the right examples for you? yes no

All Samples(63)  |  Call(26)  |  Derive(0)  |  Import(37)
Ensure we have a valid IPv6 address.

Args:
    ip_str: A string, the IPv6 address.

Returns:
    A boolean, True if this is a valid IPv6 address.

        def is_valid_ipv6_address(ip_str):
    """
    Ensure we have a valid IPv6 address.

    Args:
        ip_str: A string, the IPv6 address.

    Returns:
        A boolean, True if this is a valid IPv6 address.

    """
    from django.core.validators import validate_ipv4_address

    # We need to have at least one ':'.
    if ':' not in ip_str:
        return False

    # We can only have one '::' shortener.
    if ip_str.count('::') > 1:
        return False

    # '::' should be encompassed by start, digits or end.
    if ':::' in ip_str:
        return False

    # A single colon can neither start nor end an address.
    if ((ip_str.startswith(':') and not ip_str.startswith('::')) or
            (ip_str.endswith(':') and not ip_str.endswith('::'))):
        return False

    # We can never have more than 7 ':' (1::2:3:4:5:6:7:8 is invalid)
    if ip_str.count(':') > 7:
        return False

    # If we have no concatenation, we need to have 8 fields with 7 ':'.
    if '::' not in ip_str and ip_str.count(':') != 7:
        # We might have an IPv4 mapped address.
        if ip_str.count('.') != 3:
            return False

    ip_str = _explode_shorthand_ip_string(ip_str)

    # Now that we have that all squared away, let's check that each of the
    # hextets are between 0x0 and 0xFFFF.
    for hextet in ip_str.split(':'):
        if hextet.count('.') == 3:
            # If we have an IPv4 mapped address, the IPv4 portion has to
            # be at the end of the IPv6 portion.
            if not ip_str.split(':')[-1] == hextet:
                return False
            try:
                validate_ipv4_address(hextet)
            except ValidationError:
                return False
        else:
            try:
                # a value error here means that we got a bad hextet,
                # something like 0xzzzz
                if int(hextet, 16) < 0x0 or int(hextet, 16) > 0xFFFF:
                    return False
            except ValueError:
                return False
    return True
        


src/a/p/appscale-HEAD/AppServer/lib/django-1.5/django/core/validators.py   appscale(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
 
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

src/a/p/appscale-HEAD/AppServer/lib/django-1.4/django/core/validators.py   appscale(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.ipv6 import is_valid_ipv6_address
 
# These values, if given to validate(), will trigger the self.required check.
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_(u'Enter a valid IPv6 address.'), code='invalid')
 
def validate_ipv46_address(value):

src/h/u/hue-HEAD/desktop/core/ext-py/Django-1.4.5/django/core/validators.py   hue(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.ipv6 import is_valid_ipv6_address
 
# These values, if given to validate(), will trigger the self.required check.
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_(u'Enter a valid IPv6 address.'), code='invalid')
 
def validate_ipv46_address(value):

src/g/o/google-app-engine-HEAD/lib/django-1.5/django/core/validators.py   google-app-engine(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
 
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

src/g/o/google-app-engine-HEAD/lib/django-1.4/django/core/validators.py   google-app-engine(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.ipv6 import is_valid_ipv6_address
 
# These values, if given to validate(), will trigger the self.required check.
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_(u'Enter a valid IPv6 address.'), code='invalid')
 
def validate_ipv46_address(value):

src/s/o/socorro-HEAD/webapp-django/vendor/lib/python/django/core/validators.py   socorro(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
 
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

src/r/o/rolf-HEAD/ve/lib/python2.7/site-packages/django/core/validators.py   rolf(Download)
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/django/core/validators.py   antisocial(Download)
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

src/g/i/gitstack-HEAD/python/Lib/site-packages/django/core/validators.py   gitstack(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.ipv6 import is_valid_ipv6_address
 
# These values, if given to validate(), will trigger the self.required check.
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_(u'Enter a valid IPv6 address.'), code='invalid')
 
def validate_ipv46_address(value):

src/c/a/captain-HEAD/vendor/lib/python/django/core/validators.py   captain(Download)
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils import six
 
def validate_ipv6_address(value):
    if not is_valid_ipv6_address(value):
        raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
 
 

  1 | 2 | 3 | 4  Next