Hello community, here is the log from the commit of package python-validators for openSUSE:Factory checked in at 2019-09-23 12:03:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-validators (Old) and /work/SRC/openSUSE:Factory/.python-validators.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-validators" Mon Sep 23 12:03:18 2019 rev:7 rq:729736 version:0.14.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-validators/python-validators.changes 2019-05-27 08:38:32.527067308 +0200 +++ /work/SRC/openSUSE:Factory/.python-validators.new.7948/python-validators.changes 2019-09-23 12:03:20.525945674 +0200 @@ -1,0 +2,6 @@ +Tue Sep 10 09:25:32 UTC 2019 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 0.14.0: + * Added new validators ipv4_cidr, ipv6_cidr + +------------------------------------------------------------------- Old: ---- validators-0.13.0.tar.gz New: ---- validators-0.14.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-validators.spec ++++++ --- /var/tmp/diff_new_pack.g9KvMH/_old 2019-09-23 12:03:21.445945523 +0200 +++ /var/tmp/diff_new_pack.g9KvMH/_new 2019-09-23 12:03:21.445945523 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-validators -Version: 0.13.0 +Version: 0.14.0 Release: 0 Summary: Python Data Validation License: MIT ++++++ validators-0.13.0.tar.gz -> validators-0.14.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/CHANGES.rst new/validators-0.14.0/CHANGES.rst --- old/validators-0.13.0/CHANGES.rst 2019-05-20 09:50:32.000000000 +0200 +++ new/validators-0.14.0/CHANGES.rst 2019-08-21 09:50:01.000000000 +0200 @@ -2,6 +2,12 @@ --------- +0.14.0 (2019-08-21) +^^^^^^^^^^^^^^^^^^^ + +- Added new validators ``ipv4_cidr``, ``ipv6_cidr`` (#117, pull request courtesy woodruffw) + + 0.13.0 (2019-05-20) ^^^^^^^^^^^^^^^^^^^ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/PKG-INFO new/validators-0.14.0/PKG-INFO --- old/validators-0.13.0/PKG-INFO 2019-05-20 09:51:02.000000000 +0200 +++ new/validators-0.14.0/PKG-INFO 2019-08-21 09:54:05.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: validators -Version: 0.13.0 +Version: 0.14.0 Summary: Python Data Validation for Humans™. Home-page: https://github.com/kvesteri/validators Author: Konsta Vesterinen diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/tests/test_ipv4_cidr.py new/validators-0.14.0/tests/test_ipv4_cidr.py --- old/validators-0.13.0/tests/test_ipv4_cidr.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.0/tests/test_ipv4_cidr.py 2019-08-21 09:48:18.000000000 +0200 @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import pytest + +from validators import ipv4_cidr, ipv6_cidr, ValidationFailure + + +@pytest.mark.parametrize(('cidr',), [ + ('127.0.0.1/0',), + ('123.5.77.88/8',), + ('12.12.12.12/32',), +]) +def test_returns_true_on_valid_ipv4_cidr(cidr): + assert ipv4_cidr(cidr) + assert not ipv6_cidr(cidr) + + +@pytest.mark.parametrize(('cidr',), [ + ('abc.0.0.1',), + ('1.1.1.1',), + ('1.1.1.1/-1',), + ('1.1.1.1/33',), + ('1.1.1.1/foo',), +]) +def test_returns_failed_validation_on_invalid_ipv4_cidr(cidr): + assert isinstance(ipv4_cidr(cidr), ValidationFailure) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/tests/test_ipv6_cidr.py new/validators-0.14.0/tests/test_ipv6_cidr.py --- old/validators-0.13.0/tests/test_ipv6_cidr.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.0/tests/test_ipv6_cidr.py 2019-08-21 09:48:18.000000000 +0200 @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import pytest + +from validators import ipv4_cidr, ipv6_cidr, ValidationFailure + + +@pytest.mark.parametrize(('cidr',), [ + ('::1/0',), + ('dead:beef:0:0:0:0:42:1/8',), + ('abcd:ef::42:1/32',), + ('0:0:0:0:0:ffff:1.2.3.4/64',), + ('::192.168.30.2/128',), +]) +def test_returns_true_on_valid_ipv6_cidr(cidr): + assert ipv6_cidr(cidr) + assert not ipv4_cidr(cidr) + + +@pytest.mark.parametrize(('cidr',), [ + ('abc.0.0.1',), + ('abcd:1234::123::1',), + ('1:2:3:4:5:6:7:8:9',), + ('abcd::1ffff',), + ('1.1.1.1',), + ('::1',), + ('::1/129',), + ('::1/-1',), + ('::1/foo',), +]) +def test_returns_failed_validation_on_invalid_ipv6_cidr(cidr): + assert isinstance(ipv6_cidr(cidr), ValidationFailure) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/validators/__init__.py new/validators-0.14.0/validators/__init__.py --- old/validators-0.13.0/validators/__init__.py 2019-05-20 09:49:33.000000000 +0200 +++ new/validators-0.14.0/validators/__init__.py 2019-08-21 09:50:09.000000000 +0200 @@ -5,7 +5,7 @@ from .hashes import md5, sha1, sha224, sha256, sha512 from .i18n import fi_business_id, fi_ssn from .iban import iban -from .ip_address import ipv4, ipv6 +from .ip_address import ipv4, ipv4_cidr, ipv6, ipv6_cidr from .length import length from .mac_address import mac_address from .slug import slug @@ -16,7 +16,7 @@ __all__ = ('between', 'domain', 'email', 'Max', 'Min', 'md5', 'sha1', 'sha224', 'sha256', 'sha512', 'fi_business_id', 'fi_ssn', 'iban', 'ipv4', - 'ipv6', 'length', 'mac_address', 'slug', 'truthy', 'url', - 'ValidationFailure', 'validator', 'uuid') + 'ipv4_cidr', 'ipv6', 'ipv6_cidr', 'length', 'mac_address', 'slug', + 'truthy', 'url', 'ValidationFailure', 'validator', 'uuid') -__version__ = '0.13.0' +__version__ = '0.14.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/validators/ip_address.py new/validators-0.14.0/validators/ip_address.py --- old/validators-0.13.0/validators/ip_address.py 2018-06-03 11:52:26.000000000 +0200 +++ new/validators-0.14.0/validators/ip_address.py 2019-08-21 09:48:18.000000000 +0200 @@ -30,6 +30,31 @@ @validator +def ipv4_cidr(value): + """ + Return whether or not given value is a valid CIDR-notated IP version 4 + address range. + + This validator is based on RFC4632 3.1. + + Examples:: + + >>> ipv4_cidr('1.1.1.1/8') + True + + >>> ipv4_cidr('1.1.1.1') + ValidationFailure(func=ipv4_cidr, args={'value': '1.1.1.1'}) + """ + try: + prefix, suffix = value.split('/', 2) + except ValueError: + return False + if not ipv4(prefix) or not suffix.isdigit(): + return False + return 0 <= int(suffix) <= 32 + + +@validator def ipv6(value): """ Return whether or not given value is a valid IP version 6 address @@ -92,3 +117,28 @@ elif count_blank == 2 and not ipv6_groups[0] and not ipv6_groups[1]: return True return False + + +@validator +def ipv6_cidr(value): + """ + Returns whether or not given value is a valid CIDR-notated IP version 6 + address range. + + This validator is based on RFC4632 3.1. + + Examples:: + + >>> ipv6_cidr('::1/128') + True + + >>> ipv6_cidr('::1') + ValidationFailure(func=ipv6_cidr, args={'value': '::1'}) + """ + try: + prefix, suffix = value.split('/', 2) + except ValueError: + return False + if not ipv6(prefix) or not suffix.isdigit(): + return False + return 0 <= int(suffix) <= 128 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/validators.egg-info/PKG-INFO new/validators-0.14.0/validators.egg-info/PKG-INFO --- old/validators-0.13.0/validators.egg-info/PKG-INFO 2019-05-20 09:51:02.000000000 +0200 +++ new/validators-0.14.0/validators.egg-info/PKG-INFO 2019-08-21 09:54:05.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: validators -Version: 0.13.0 +Version: 0.14.0 Summary: Python Data Validation for Humans™. Home-page: https://github.com/kvesteri/validators Author: Konsta Vesterinen diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.13.0/validators.egg-info/SOURCES.txt new/validators-0.14.0/validators.egg-info/SOURCES.txt --- old/validators-0.13.0/validators.egg-info/SOURCES.txt 2019-05-20 09:51:02.000000000 +0200 +++ new/validators-0.14.0/validators.egg-info/SOURCES.txt 2019-08-21 09:54:05.000000000 +0200 @@ -14,7 +14,9 @@ tests/test_extremes.py tests/test_iban.py tests/test_ipv4.py +tests/test_ipv4_cidr.py tests/test_ipv6.py +tests/test_ipv6_cidr.py tests/test_length.py tests/test_mac_address.py tests/test_md5.py