python-stdnum branch master updated. 1.8.1-11-g6e30cf5
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.8.1-11-g6e30cf5
- 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.8.1-11-g6e30cf5
- Date: Sun, 11 Mar 2018 14:29:41 +0100 (CET)
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 6e30cf59a225459485f380d5c03f27b9b18fca98 (commit)
from 70dc091ac2db689f3405976b858b90f4924b6835 (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 -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=6e30cf59a225459485f380d5c03f27b9b18fca98
commit 6e30cf59a225459485f380d5c03f27b9b18fca98
Author: Esa Halsti <esa.halsti@taitoa.fi>
Date: Wed Feb 28 16:06:48 2018 +0200
Add validation for "individual" part of hetu
The range between 900 and 999 is reserved for temporary identifiers and
is not given to any real person.
Closes https://github.com/arthurdejong/python-stdnum/pull/66
diff --git a/stdnum/fi/hetu.py b/stdnum/fi/hetu.py
index 88230dd..3fda6a9 100644
--- a/stdnum/fi/hetu.py
+++ b/stdnum/fi/hetu.py
@@ -91,6 +91,9 @@ def validate(number):
# for historical reasons individual IDs start from 002
if individual < 2:
raise InvalidComponent()
+ # this range is for temporary identifiers
+ if 900 <= individual <= 999:
+ raise InvalidComponent()
checkable_number = '%02d%02d%02d%03d' % (day, month, year, individual)
if match.group('control') != _calc_checksum(checkable_number):
raise InvalidChecksum()
diff --git a/tests/test_fi_hetu.doctest b/tests/test_fi_hetu.doctest
index d68d12f..b5b3f87 100644
--- a/tests/test_fi_hetu.doctest
+++ b/tests/test_fi_hetu.doctest
@@ -78,13 +78,17 @@ Traceback (most recent call last):
InvalidFormat: ...
-Invalid individual number:
-(for historical reasons individual IDs start from 002)
+Invalid individual number: (for historical reasons individual IDs start from
+002 and the range from 900 to 999 is used as temporary identifiers)
>>> hetu.validate('131052-000V')
Traceback (most recent call last):
...
InvalidComponent: ...
+>>> hetu.validate('131052-9993')
+Traceback (most recent call last):
+ ...
+InvalidComponent: ...
compact() and format() don't do much special:
-----------------------------------------------------------------------
Summary of changes:
stdnum/fi/hetu.py | 3 +++
tests/test_fi_hetu.doctest | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.8.1-11-g6e30cf5,
Commits of the python-stdnum project