Hello community,

here is the log from the commit of package python-validators for 
openSUSE:Factory checked in at 2019-05-27 08:38:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-validators (Old)
 and      /work/SRC/openSUSE:Factory/.python-validators.new.5148 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-validators"

Mon May 27 08:38:31 2019 rev:6 rq:705296 version:0.13.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-validators/python-validators.changes      
2019-05-24 11:31:02.497411774 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-validators.new.5148/python-validators.changes
    2019-05-27 08:38:32.527067308 +0200
@@ -1,0 +2,6 @@
+Fri May 24 19:11:44 UTC 2019 - Tomáš Chvátal <tchva...@suse.com>
+
+- Update to 0.13.0:
+  * Added new validator: es_doi, es_nif, es_cif, es_nie (#121, pull request 
courtesy kingbuzzman)
+
+-------------------------------------------------------------------

Old:
----
  validators-0.12.6.tar.gz

New:
----
  validators-0.13.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-validators.spec ++++++
--- /var/tmp/diff_new_pack.UjDHsa/_old  2019-05-27 08:38:33.103067083 +0200
+++ /var/tmp/diff_new_pack.UjDHsa/_new  2019-05-27 08:38:33.107067082 +0200
@@ -18,26 +18,25 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-validators
-Version:        0.12.6
+Version:        0.13.0
 Release:        0
 Summary:        Python Data Validation
 License:        MIT
 Group:          Development/Languages/Python
-Url:            https://github.com/kvesteri/validators
+URL:            https://github.com/kvesteri/validators
 Source:         
https://files.pythonhosted.org/packages/source/v/validators/validators-%{version}.tar.gz
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
+Requires:       python-decorator >= 3.4.0
+Requires:       python-six >= 1.4.0
+BuildArch:      noarch
 # SECTION test requirements
 BuildRequires:  %{python_module decorator >= 3.4.0}
-BuildRequires:  %{python_module nose}
+BuildRequires:  %{python_module isort >= 4.2.2}
 BuildRequires:  %{python_module pytest}
 BuildRequires:  %{python_module six >= 1.4.0}
 # /SECTION
-Requires:       python-decorator >= 3.4.0
-Requires:       python-six >= 1.4.0
-BuildArch:      noarch
-
 %python_subpackages
 
 %description

++++++ validators-0.12.6.tar.gz -> validators-0.13.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/CHANGES.rst 
new/validators-0.13.0/CHANGES.rst
--- old/validators-0.12.6/CHANGES.rst   2019-05-08 08:47:31.000000000 +0200
+++ new/validators-0.13.0/CHANGES.rst   2019-05-20 09:50:32.000000000 +0200
@@ -2,6 +2,12 @@
 ---------
 
 
+0.13.0 (2019-05-20)
+^^^^^^^^^^^^^^^^^^^
+
+- Added new validator: ``es_doi``, ``es_nif``, ``es_cif``, ``es_nie`` (#121, 
pull request courtesy kingbuzzman)
+
+
 0.12.6 (2019-05-08)
 ^^^^^^^^^^^^^^^^^^^
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/PKG-INFO 
new/validators-0.13.0/PKG-INFO
--- old/validators-0.12.6/PKG-INFO      2019-05-08 08:49:11.000000000 +0200
+++ new/validators-0.13.0/PKG-INFO      2019-05-20 09:51:02.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: validators
-Version: 0.12.6
+Version: 0.13.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.12.6/docs/index.rst 
new/validators-0.13.0/docs/index.rst
--- old/validators-0.12.6/docs/index.rst        2017-06-03 16:07:19.000000000 
+0200
+++ new/validators-0.13.0/docs/index.rst        2019-05-20 09:49:33.000000000 
+0200
@@ -32,7 +32,8 @@
     pip install validators
 
 
-Currently ``validators`` supports python versions 2.7, 3.3, 3.4, 3.5 and PyPy.
+Currently ``validators`` supports python versions 2.7, 3.3, 3.4, 3.5, 3.6, 3.7
+and PyPy.
 
 
 Basic validators
@@ -193,6 +194,32 @@
 i18n validators
 ===============
 
+Spanish
+-------
+
+.. module:: validators.i18n.es
+
+es_doi
+^^^^^^
+
+.. autofunction:: es_doi
+
+es_nif
+^^^^^^
+
+.. autofunction:: es_nif
+
+es_nie
+^^^^^^
+
+.. autofunction:: es_nie
+
+es_cif
+^^^^^^
+
+.. autofunction:: es_cif
+
+
 Finnish
 -------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/tests/i18n/test_es.py 
new/validators-0.13.0/tests/i18n/test_es.py
--- old/validators-0.12.6/tests/i18n/test_es.py 1970-01-01 01:00:00.000000000 
+0100
+++ new/validators-0.13.0/tests/i18n/test_es.py 2019-05-20 09:49:33.000000000 
+0200
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+import pytest
+
+from validators import ValidationFailure
+from validators.i18n.es import es_cif, es_doi, es_nie, es_nif
+
+
+@pytest.mark.parametrize(('value',), [
+    ('B25162520',),
+    ('U4839822F',),
+    ('B96817697',),
+    ('P7067074J',),
+    ('Q7899705C',),
+    ('C75098681',),
+    ('G76061860',),
+    ('C71345375',),
+    ('G20558169',),
+    ('U5021960I',),
+])
+def test_returns_true_on_valid_cif(value):
+    assert es_cif(value)
+
+
+@pytest.mark.parametrize(('value',), [
+    ('12345',),
+    ('ABCDEFGHI',),
+    ('Z5021960I',),
+])
+def test_returns_false_on_invalid_cif(value):
+    result = es_cif(value)
+    assert isinstance(result, ValidationFailure)
+
+
+@pytest.mark.parametrize(('value',), [
+    ('X0095892M',),
+    ('X8868108K',),
+    ('X2911154K',),
+    ('Y2584969J',),
+    ('X7536157T',),
+    ('Y5840388N',),
+    ('Z2915723H',),
+    ('Y4002236C',),
+    ('X7750702R',),
+    ('Y0408759V',),
+])
+def test_returns_true_on_valid_nie(value):
+    assert es_nie(value)
+
+
+@pytest.mark.parametrize(('value',), [
+    ('K0000023T',),
+    ('L0000024R',),
+    ('M0000025W',),
+    ('00000026A',),
+    ('00000027G',),
+    ('00000028M',),
+    ('00000029Y',),
+    ('00000030F',),
+    ('00000031P',),
+    ('00000032D',),
+    ('00000033X',),
+    ('00000034B',),
+    ('00000035N',),
+    ('00000036J',),
+    ('00000037Z',),
+    ('00000038S',),
+    ('00000039Q',),
+    ('00000040V',),
+    ('00000041H',),
+    ('00000042L',),
+    ('00000043C',),
+    ('00000044K',),
+    ('00000045E',),
+])
+def test_returns_true_on_valid_nif(value):
+    assert es_nif(value)
+
+
+@pytest.mark.parametrize(('value',), [
+    ('12345',),
+    ('X0000000T',),
+    ('00000000T',),
+    ('00000001R',),
+])
+def test_returns_false_on_invalid_nif(value):
+    result = es_nif(value)
+    assert isinstance(result, ValidationFailure)
+
+
+@pytest.mark.parametrize(('value',), [
+    # CIFs
+    ('B25162520',),
+    ('U4839822F',),
+    ('B96817697',),
+    # NIEs
+    ('X0095892M',),
+    ('X8868108K',),
+    ('X2911154K',),
+    # NIFs
+    ('26643189N',),
+    ('07060225F',),
+    ('49166693F',),
+])
+def test_returns_true_on_valid_doi(value):
+    assert es_doi(value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/tests/i18n/test_fi.py 
new/validators-0.13.0/tests/i18n/test_fi.py
--- old/validators-0.12.6/tests/i18n/test_fi.py 2018-11-13 13:11:17.000000000 
+0100
+++ new/validators-0.13.0/tests/i18n/test_fi.py 2019-05-20 09:49:33.000000000 
+0200
@@ -1,7 +1,8 @@
 # -*- coding: utf-8 -*-
 import pytest
 
-from validators import fi_business_id, fi_ssn, ValidationFailure
+from validators import ValidationFailure
+from validators.i18n.fi import fi_business_id, fi_ssn
 
 
 @pytest.mark.parametrize(('value',), [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/validators/__init__.py 
new/validators-0.13.0/validators/__init__.py
--- old/validators-0.12.6/validators/__init__.py        2019-05-08 
08:47:35.000000000 +0200
+++ new/validators-0.13.0/validators/__init__.py        2019-05-20 
09:49:33.000000000 +0200
@@ -1,17 +1,22 @@
-from .between import between  # noqa
-from .domain import domain  # noqa
-from .email import email  # noqa
-from .extremes import Max, Min  # noqa
-from .hashes import md5, sha1, sha224, sha256, sha512  # noqa
-from .i18n import fi_business_id, fi_ssn  # noqa
-from .iban import iban  # noqa
-from .ip_address import ipv4, ipv6  # noqa
-from .length import length  # noqa
-from .mac_address import mac_address  # noqa
-from .slug import slug  # noqa
-from .truthy import truthy  # noqa
-from .url import url  # noqa
-from .utils import ValidationFailure, validator  # noqa
-from .uuid import uuid  # noqa
+from .between import between
+from .domain import domain
+from .email import email
+from .extremes import Max, Min
+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 .length import length
+from .mac_address import mac_address
+from .slug import slug
+from .truthy import truthy
+from .url import url
+from .utils import ValidationFailure, validator
+from .uuid import uuid
 
-__version__ = '0.12.6'
+__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')
+
+__version__ = '0.13.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/validators/i18n/__init__.py 
new/validators-0.13.0/validators/i18n/__init__.py
--- old/validators-0.12.6/validators/i18n/__init__.py   2015-10-10 
08:47:54.000000000 +0200
+++ new/validators-0.13.0/validators/i18n/__init__.py   2019-05-20 
09:49:33.000000000 +0200
@@ -1 +1,4 @@
+# TODO: remove, let the user import it if they really want it
 from .fi import fi_business_id, fi_ssn  # noqa
+
+__all__ = ('fi_business_id', 'fi_ssn')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/validators/i18n/es.py 
new/validators-0.13.0/validators/i18n/es.py
--- old/validators-0.12.6/validators/i18n/es.py 1970-01-01 01:00:00.000000000 
+0100
+++ new/validators-0.13.0/validators/i18n/es.py 2019-05-20 09:49:33.000000000 
+0200
@@ -0,0 +1,200 @@
+# -*- coding: utf-8 -*-
+from validators.utils import validator
+
+__all__ = ('es_cif', 'es_nif', 'es_nie', 'es_doi',)
+
+
+def nif_nie_validation(doi, number_by_letter, special_cases):
+    """
+    Validate if the doi is a NIF or a NIE.
+    :param doi: DOI to validate.
+    :return: boolean if it's valid.
+    """
+    doi = doi.upper()
+    if doi in special_cases:
+        return False
+
+    table = 'TRWAGMYFPDXBNJZSQVHLCKE'
+
+    if len(doi) != 9:
+        return False
+
+    control = doi[8]
+
+    # If it is not a DNI, convert the first letter to the corresponding
+    # digit
+    numbers = number_by_letter.get(doi[0], doi[0]) + doi[1:8]
+
+    return numbers.isdigit() and control == table[int(numbers) % 23]
+
+
+@validator
+def es_cif(doi):
+    """
+    Validate a Spanish CIF.
+
+    Each company in Spain prior to 2008 had a distinct CIF and has been
+    discontinued. For more information see `wikipedia.org/cif`_.
+
+    The new replacement is to use NIF for absolutely everything. The issue is
+    that there are "types" of NIFs now: company, person[citizen vs recident]
+    all distinguished by the first character of the DOI. For this reason we
+    will continue to call CIF NIFs that are used for companies.
+
+    This validator is based on `generadordni.es`_.
+
+    .. _generadordni.es:
+        https://generadordni.es/
+
+    .. _wikipedia.org/cif:
+        https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal
+
+    Examples::
+
+        >>> es_cif('B25162520')
+        True
+
+        >>> es_cif('B25162529')
+        ValidationFailure(func=es_cif, args=...)
+
+    .. versionadded:: 0.13.0
+
+    :param doi: DOI to validate
+    """
+    doi = doi.upper()
+
+    if len(doi) != 9:
+        return False
+
+    table = 'JABCDEFGHI'
+    first_chr = doi[0]
+    doi_body = doi[1:8]
+    control = doi[8]
+
+    if not doi_body.isdigit():
+        return False
+
+    odd_result = 0
+    even_result = 0
+    for index, char in enumerate(doi_body):
+        if index % 2 == 0:
+            # Multiply each each odd position doi digit by 2 and sum it all
+            # together
+            odd_result += sum(map(int, str(int(char) * 2)))
+        else:
+            even_result += int(char)
+
+    res = (10 - (even_result + odd_result) % 10) % 10
+
+    if first_chr in 'ABEH':  # Number type
+        return str(res) == control
+    elif first_chr in 'PSQW':  # Letter type
+        return table[res] == control
+    elif first_chr not in 'CDFGJNRUV':
+        return False
+
+    return control == str(res) or control == table[res]
+
+
+@validator
+def es_nif(doi):
+    """
+    Validate a Spanish NIF.
+
+    Each entity, be it person or company in Spain has a distinct NIF. Since
+    we've designated CIF to be a company NIF, this NIF is only for person.
+    For more information see `wikipedia.org/nif`_.
+
+    This validator is based on `generadordni.es`_.
+
+    .. _generadordni.es:
+        https://generadordni.es/
+
+    .. _wikipedia.org/nif:
+        https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
+
+    Examples::
+
+        >>> es_nif('26643189N')
+        True
+
+        >>> es_nif('26643189X')
+        ValidationFailure(func=es_nif, args=...)
+
+    .. versionadded:: 0.13.0
+
+    :param doi: DOI to validate
+    """
+    number_by_letter = {'L': '0', 'M': '0', 'K': '0'}
+    special_cases = ['X0000000T', '00000000T', '00000001R']
+    return nif_nie_validation(doi, number_by_letter, special_cases)
+
+
+@validator
+def es_nie(doi):
+    """
+    Validate a Spanish NIE.
+
+    The NIE is a tax identification number in Spain, known in Spanish as the
+    NIE, or more formally the Número de identidad de extranjero. For more
+    information see `wikipedia.org/nie`_.
+
+    This validator is based on `generadordni.es`_.
+
+    .. _generadordni.es:
+        https://generadordni.es/
+
+    .. _wikipedia.org/nie:
+        https://es.wikipedia.org/wiki/N%C3%BAmero_de_identidad_de_extranjero
+
+    Examples::
+
+        >>> es_nie('X0095892M')
+        True
+
+        >>> es_nie('X0095892X')
+        ValidationFailure(func=es_nie, args=...)
+
+    .. versionadded:: 0.13.0
+
+    :param doi: DOI to validate
+    """
+    number_by_letter = {'X': '0', 'Y': '1', 'Z': '2'}
+    special_cases = ['X0000000T']
+
+    # NIE must must start with X Y or Z
+    if not doi or doi[0] not in number_by_letter.keys():
+        return False
+
+    return nif_nie_validation(doi, number_by_letter, special_cases)
+
+
+@validator
+def es_doi(doi):
+    """
+    Validate a Spanish DOI.
+
+    A DOI in spain is all NIF / CIF / NIE / DNI -- a digital ID. For more
+    information see `wikipedia.org/doi`_.
+
+    This validator is based on `generadordni.es`_.
+
+    .. _generadordni.es:
+        https://generadordni.es/
+
+    .. _wikipedia.org/doi:
+        https://es.wikipedia.org/wiki/Identificador_de_objeto_digital
+
+    Examples::
+
+        >>> es_doi('X0095892M')
+        True
+
+        >>> es_doi('X0095892X')
+        ValidationFailure(func=es_doi, args=...)
+
+    .. versionadded:: 0.13.0
+
+    :param doi: DOI to validate
+    """
+    return es_nie(doi) or es_nif(doi) or es_cif(doi)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validators-0.12.6/validators.egg-info/PKG-INFO 
new/validators-0.13.0/validators.egg-info/PKG-INFO
--- old/validators-0.12.6/validators.egg-info/PKG-INFO  2019-05-08 
08:49:11.000000000 +0200
+++ new/validators-0.13.0/validators.egg-info/PKG-INFO  2019-05-20 
09:51:02.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: validators
-Version: 0.12.6
+Version: 0.13.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.12.6/validators.egg-info/SOURCES.txt 
new/validators-0.13.0/validators.egg-info/SOURCES.txt
--- old/validators-0.12.6/validators.egg-info/SOURCES.txt       2019-05-08 
08:49:11.000000000 +0200
+++ new/validators-0.13.0/validators.egg-info/SOURCES.txt       2019-05-20 
09:51:02.000000000 +0200
@@ -27,6 +27,7 @@
 tests/test_uuid.py
 tests/test_validation_failure.py
 tests/i18n/__init__.py
+tests/i18n/test_es.py
 tests/i18n/test_fi.py
 validators/__init__.py
 validators/between.py
@@ -50,4 +51,5 @@
 validators.egg-info/requires.txt
 validators.egg-info/top_level.txt
 validators/i18n/__init__.py
+validators/i18n/es.py
 validators/i18n/fi.py
\ No newline at end of file


Reply via email to