python-stdnum commit: r159 - in python-stdnum: . stdnum stdnum/hr
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum commit: r159 - in python-stdnum: . stdnum stdnum/hr
- 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 commit: r159 - in python-stdnum: . stdnum stdnum/hr
- Date: Wed, 22 Feb 2012 22:17:29 +0100 (CET)
Author: arthur
Date: Wed Feb 22 22:17:28 2012
New Revision: 159
URL: http://arthurdejong.org/viewvc/python-stdnum?revision=159&view=revision
Log:
add an OIB (Osobni identifikacijski broj, Croatian personal identification
number) module
Added:
python-stdnum/stdnum/hr/
python-stdnum/stdnum/hr/__init__.py
python-stdnum/stdnum/hr/oib.py
Modified:
python-stdnum/README
python-stdnum/stdnum/__init__.py
Modified: python-stdnum/README
==============================================================================
--- python-stdnum/README Mon Feb 20 23:22:18 2012 (r158)
+++ python-stdnum/README Wed Feb 22 22:17:28 2012 (r159)
@@ -32,6 +32,7 @@
* CNP (Cod Numeric Personal, Romanian Numerical Personal Code)
* EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
* PNF (ЛНЧ, Личен номер на чужденец, Bulgarian personal number of a foreigner)
+ * OIB (Osobni identifikacijski broj, Croatian personal identification number)
* NIF (Número de Identificación Fiscal, Spanish VAT number)
* FPA, ΦΠΑ (Foros Prostithemenis Aksias, the Greek VAT number)
* Ust ID Nr. (Umsatzsteur Identifikationnummer, the German VAT number)
Modified: python-stdnum/stdnum/__init__.py
==============================================================================
--- python-stdnum/stdnum/__init__.py Mon Feb 20 23:22:18 2012 (r158)
+++ python-stdnum/stdnum/__init__.py Wed Feb 22 22:17:28 2012 (r159)
@@ -46,6 +46,7 @@
* CNP (Cod Numeric Personal, Romanian Numerical Personal Code)
* EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
* PNF (ЛНЧ, Личен номер на чужденец, Bulgarian personal number of a foreigner)
+ * OIB (Osobni identifikacijski broj, Croatian personal identification number)
* NIF (Número de Identificación Fiscal, Spanish VAT number)
* FPA, ΦΠΑ (Foros Prostithemenis Aksias, the Greek VAT number)
* Ust ID Nr. (Umsatzsteur Identifikationnummer, the German VAT number)
Added: python-stdnum/stdnum/hr/__init__.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ python-stdnum/stdnum/hr/__init__.py Wed Feb 22 22:17:28 2012 (r159)
@@ -0,0 +1,21 @@
+# __init__.py - collection of Croatian numbers
+# coding: utf-8
+#
+# Copyright (C) 2012 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
+
+"""Collection of Croatian numbers."""
Added: python-stdnum/stdnum/hr/oib.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ python-stdnum/stdnum/hr/oib.py Wed Feb 22 22:17:28 2012 (r159)
@@ -0,0 +1,57 @@
+# cnp.py - functions for handling Croatian OIB numbers
+# coding: utf-8
+#
+# Copyright (C) 2012 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
+
+"""Module for handling Croatian OIB numbers (Osobni identifikacijski broj,
+personal identification number).
+
+The number is used to identify persons and legal entities and has 11
+digits (sometimes prefixed by HR), contains no personal information and
+uses the ISO 7064 Mod 11, 10 checksum algorithm.
+
+>>> compact('HR 33392005961')
+'33392005961'
+>>> is_valid('33392005961')
+True
+>>> is_valid('33392005962') # invalid check digit
+False
+"""
+
+from stdnum.util import clean
+from stdnum.iso7064 import mod_11_10
+
+
+def compact(number):
+ """Convert the number to the minimal representation. This strips the
+ number of any valid separators and removes surrounding whitespace."""
+ number = clean(number, ' -').upper().strip()
+ if number.startswith('HR'):
+ number = number[2:]
+ return number
+
+
+def is_valid(number):
+ """Checks to see if the number provided is a valid OIB number. This
+ checks the length, formatting and check digit."""
+ try:
+ number = compact(number)
+ except:
+ return False
+ return len(number) == 11 and number.isdigit() and \
+ mod_11_10.is_valid(number)
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum commit: r159 - in python-stdnum: . stdnum stdnum/hr,
Commits of the python-stdnum project