python-stdnum branch master updated. 1.3-18-g2409ee9
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.3-18-g2409ee9
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.3-18-g2409ee9
- Date: Tue, 26 Jul 2016 14:39:54 +0200 (CEST)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via 2409ee943859b11539be67b11da078e15e2bdc0d (commit)
from 43b58d331a8e61694a5a9b77fa0968fa326f52cc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://arthurdejong.org/git/python-stdnum/commit/?id=2409ee943859b11539be67b11da078e15e2bdc0d
commit 2409ee943859b11539be67b11da078e15e2bdc0d
Author: Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
Date: Sun May 22 20:09:21 2016 +0200
Add NIF - French tax identification number
Add module for NIF also known as SPI number.
diff --git a/stdnum/fr/nif.py b/stdnum/fr/nif.py
new file mode 100644
index 0000000..7d5a802
--- /dev/null
+++ b/stdnum/fr/nif.py
@@ -0,0 +1,75 @@
+# nif.py - functions for handling French tax identification numbers
+# coding: utf-8
+#
+# Copyright (C) 2016 Dimitri Papadopoulos
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+"""NIF (Numéro d'Immatriculation Fiscale, French tax identification number).
+
+The NIF (Numéro d'Immatriculation Fiscale, Numéro d'Identité Fiscale or
+Numéro d'Identification Fiscale) also known as numéro fiscal de référence or
+SPI (Simplification des Procédures d'Identification) is a 13-digit number
+issued by the French tax authorities to people for tax reporting purposes.
+
+More information:
+
+* https://ec.europa.eu/taxation_customs/tin/tinByCountry.html
+* https://fr.wikipedia.org/wiki/Num%C3%A9ro_d%27Immatriculation_Fiscale#France
+
+>>> validate('0701987765432')
+'0701987765432'
+>>> validate('070198776543')
+Traceback (most recent call last):
+ ...
+InvalidLength: ...
+>>> format('295109912611193')
+'2 95 10 99 126 111 93'
+"""
+
+from stdnum.exceptions import *
+from stdnum.util import clean
+
+
+def compact(number):
+ """Convert the number to the minimal representation. This strips the
+ number of any valid separators and removes surrounding whitespace."""
+ return clean(number, ' ').strip()
+
+
+def validate(number):
+ """Checks the length to see if the number provided is valid."""
+ number = compact(number)
+ if not number.isdigit():
+ raise InvalidFormat()
+ if len(number) != 13:
+ raise InvalidLength()
+ return number
+
+
+def is_valid(number):
+ """Checks the length to see if the number provided is valid."""
+ try:
+ return bool(validate(number))
+ except ValidationError:
+ return False
+
+
+def format(number):
+ """Reformat the passed number to the standard format."""
+ number = compact(number)
+ return ' '.join((number[:2], number[2:4], number[4:7],
+ number[7:10], number[10:]))
-----------------------------------------------------------------------
Summary of changes:
stdnum/{no/orgnr.py => fr/nif.py} | 50 ++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 27 deletions(-)
copy stdnum/{no/orgnr.py => fr/nif.py} (57%)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.3-18-g2409ee9,
Commits of the python-stdnum project