lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 0.8.1-10-g73d05b0

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 0.8.1-10-g73d05b0



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  73d05b0a352089131b80de57a3b705425a44e6c6 (commit)
       via  73330a1a09b1b94ca85390a84c6a64815d3bdc45 (commit)
      from  188d3eac0f043de8d06ec260a691ef76973b7d9b (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=73d05b0a352089131b80de57a3b705425a44e6c6

commit 73d05b0a352089131b80de57a3b705425a44e6c6
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sat Nov 9 15:13:10 2013 +0100

    Add a Dutch Brin number module
    
    The Brin (Basis Registratie Instellingen) is a number to identify
    schools and related institutions.
    
    Addresses trac ticket #6.

diff --git a/stdnum/nl/brin.py b/stdnum/nl/brin.py
new file mode 100644
index 0000000..1975f77
--- /dev/null
+++ b/stdnum/nl/brin.py
@@ -0,0 +1,80 @@
+# brin.py - functions for handling Brin numbers
+#
+# Copyright (C) 2013 Arthur de Jong
+#
+# 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
+
+"""Brin number (Dutch number for schools).
+
+The Brin (Basis Registratie Instellingen) is a number to identify schools
+and related institutions. The number consists of four alphanumeric
+characters, sometimes extended with two digits to indicate the site (this
+complete code is called the vestigingsnummer).
+
+The register of these numbers can be downloaded from:
+http://www.duo.nl/organisatie/open_onderwijsdata/databestanden/default.asp
+
+>>> validate('05 KO')
+'05KO'
+>>> validate('07NU 00')
+'07NU00'
+>>> validate('12KB1')
+Traceback (most recent call last):
+    ...
+InvalidLength: ...
+>>> validate('30AJ0A')  # location code has letter
+Traceback (most recent call last):
+    ...
+InvalidFormat: ...
+"""
+
+import re
+
+from stdnum.exceptions import *
+from stdnum.util import clean
+
+
+# this regular expression is based on what was found in the online
+# database: the first two digits are always numeric, followed by two
+# letters and an optional two letter location identifier
+_brin_re = re.compile(r'^(?P<brin>[0-9]{2}[A-Z]{2})(?P<location>[0-9]{2})?$')
+
+
+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, ' -.').upper().strip()
+
+
+def validate(number):
+    """Checks to see if the number provided is in the correct format.
+    This currently does not check whether the number points to a
+    registered school."""
+    number = compact(number)
+    if len(number) not in (4, 6):
+        raise InvalidLength()
+    match = _brin_re.search(number)
+    if not match:
+        raise InvalidFormat()
+    return number
+
+
+def is_valid(number):
+    """Checks to see if the number provided is a valid Brin number."""
+    try:
+        return bool(validate(number))
+    except ValidationError:
+        return False

http://arthurdejong.org/git/python-stdnum/commit/?id=73330a1a09b1b94ca85390a84c6a64815d3bdc45

commit 73330a1a09b1b94ca85390a84c6a64815d3bdc45
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sat Nov 9 14:28:24 2013 +0100

    Clarify onderwijsnummer description

diff --git a/stdnum/nl/onderwijsnummer.py b/stdnum/nl/onderwijsnummer.py
index db29fa1..0fbb3fc 100644
--- a/stdnum/nl/onderwijsnummer.py
+++ b/stdnum/nl/onderwijsnummer.py
@@ -17,11 +17,11 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-"""Onderwijsnummer (Dutch school number).
+"""Onderwijsnummer (Dutch student school number).
 
-The onderwijsnummers (school number) is very similar to the BSN (Dutch
-national identification number) but for students without a BSN. It uses a
-small variation of the BSN checksum.
+The onderwijsnummers (education number) is very similar to the BSN (Dutch
+national identification number) for students without a BSN. It uses a
+checksum mechanism similar to the BSN.
 
 >>> validate('1012.22.331')
 '101222331'

-----------------------------------------------------------------------

Summary of changes:
 stdnum/{bg/pnf.py => nl/brin.py} |   62 ++++++++++++++++++++------------------
 stdnum/nl/onderwijsnummer.py     |    8 ++---
 2 files changed, 37 insertions(+), 33 deletions(-)
 copy stdnum/{bg/pnf.py => nl/brin.py} (51%)


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/