当前位置: 首页>>代码示例>>Python>>正文


Python ipv6.clean_ipv6_address方法代码示例

本文整理汇总了Python中django.utils.ipv6.clean_ipv6_address方法的典型用法代码示例。如果您正苦于以下问题:Python ipv6.clean_ipv6_address方法的具体用法?Python ipv6.clean_ipv6_address怎么用?Python ipv6.clean_ipv6_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.ipv6的用法示例。


在下文中一共展示了ipv6.clean_ipv6_address方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value in self.empty_values:
            return ''
        value = value.strip()
        if value and ':' in value:
            return clean_ipv6_address(value, self.unpack_ipv4)
        return value 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:9,代码来源:fields.py

示例2: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value and ':' in value:
            return clean_ipv6_address(value,
                self.unpack_ipv4, self.error_messages['invalid'])
        return value 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:__init__.py

示例3: get_prep_value

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def get_prep_value(self, value):
        value = super(GenericIPAddressField, self).get_prep_value(value)
        if value is None:
            return None
        if value and ':' in value:
            try:
                return clean_ipv6_address(value, self.unpack_ipv4)
            except exceptions.ValidationError:
                pass
        return six.text_type(value) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:12,代码来源:__init__.py

示例4: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value is None:
            return None
        if not isinstance(value, str):
            value = str(value)
        value = value.strip()
        if ':' in value:
            return clean_ipv6_address(value, self.unpack_ipv4, self.error_messages['invalid'])
        return value 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:11,代码来源:__init__.py

示例5: get_prep_value

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def get_prep_value(self, value):
        value = super().get_prep_value(value)
        if value is None:
            return None
        if value and ':' in value:
            try:
                return clean_ipv6_address(value, self.unpack_ipv4)
            except exceptions.ValidationError:
                pass
        return str(value) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:12,代码来源:__init__.py

示例6: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value is None:
            return None
        if not isinstance(value, six.string_types):
            value = force_text(value)
        value = value.strip()
        if ':' in value:
            return clean_ipv6_address(value, self.unpack_ipv4, self.error_messages['invalid'])
        return value 
开发者ID:Yeah-Kun,项目名称:python,代码行数:11,代码来源:__init__.py

示例7: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value in validators.EMPTY_VALUES:
            return ''
        if value and ':' in value:
                return clean_ipv6_address(value,
                    self.unpack_ipv4, self.error_messages['invalid'])
        return value 
开发者ID:blackye,项目名称:luscan-devel,代码行数:9,代码来源:fields.py

示例8: get_prep_value

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def get_prep_value(self, value):
        if value and ':' in value:
            try:
                return clean_ipv6_address(value, self.unpack_ipv4)
            except exceptions.ValidationError:
                pass
        return value 
开发者ID:blackye,项目名称:luscan-devel,代码行数:9,代码来源:__init__.py

示例9: to_python

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_python(self, value):
        if value is None:
            return None
        if not isinstance(value, six.string_types):
            value = force_text(value)
        value = value.strip()
        if ':' in value:
            return clean_ipv6_address(value,
                self.unpack_ipv4, self.error_messages['invalid'])
        return value 
开发者ID:drexly,项目名称:openhgsenti,代码行数:12,代码来源:__init__.py

示例10: to_internal_value

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def to_internal_value(self, data):
        if not isinstance(data, six.string_types):
            self.fail('invalid', value=data)

        if ':' in data:
            try:
                if self.protocol in ('both', 'ipv6'):
                    return clean_ipv6_address(data, self.unpack_ipv4)
            except DjangoValidationError:
                self.fail('invalid', value=data)

        return super(IPAddressField, self).to_internal_value(data)


# Number types... 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:17,代码来源:fields.py

示例11: test_cleans_plain_address

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def test_cleans_plain_address(self):
        self.assertEqual(clean_ipv6_address('DEAD::0:BEEF'), 'dead::beef')
        self.assertEqual(clean_ipv6_address('2001:000:a:0000:0:fe:fe:beef'), '2001:0:a::fe:fe:beef')
        self.assertEqual(clean_ipv6_address('2001::a:0000:0:fe:fe:beef'), '2001:0:a::fe:fe:beef') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_ipv6.py

示例12: test_cleans_with_v4_mapping

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def test_cleans_with_v4_mapping(self):
        self.assertEqual(clean_ipv6_address('::ffff:0a0a:0a0a'), '::ffff:10.10.10.10')
        self.assertEqual(clean_ipv6_address('::ffff:1234:1234'), '::ffff:18.52.18.52')
        self.assertEqual(clean_ipv6_address('::ffff:18.52.18.52'), '::ffff:18.52.18.52')
        self.assertEqual(clean_ipv6_address('::ffff:0.52.18.52'), '::ffff:0.52.18.52')
        self.assertEqual(clean_ipv6_address('::ffff:0.0.0.0'), '::ffff:0.0.0.0') 
开发者ID:nesdis,项目名称:djongo,代码行数:8,代码来源:test_ipv6.py

示例13: test_unpacks_ipv4

# 需要导入模块: from django.utils import ipv6 [as 别名]
# 或者: from django.utils.ipv6 import clean_ipv6_address [as 别名]
def test_unpacks_ipv4(self):
        self.assertEqual(clean_ipv6_address('::ffff:0a0a:0a0a', unpack_ipv4=True), '10.10.10.10')
        self.assertEqual(clean_ipv6_address('::ffff:1234:1234', unpack_ipv4=True), '18.52.18.52')
        self.assertEqual(clean_ipv6_address('::ffff:18.52.18.52', unpack_ipv4=True), '18.52.18.52') 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_ipv6.py


注:本文中的django.utils.ipv6.clean_ipv6_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。