lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.1-12-g7f9c94f

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

python-stdnum branch master updated. 1.1-12-g7f9c94f



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  7f9c94f99dcaed8c97d6288d9fbbc483a963c2d7 (commit)
      from  0cbba6e73ff63ff03407789a7de884fe0edc4b22 (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=7f9c94f99dcaed8c97d6288d9fbbc483a963c2d7

commit 7f9c94f99dcaed8c97d6288d9fbbc483a963c2d7
Author: Lari Haataja <lari@holvi.com>
Date:   Fri Jun 12 14:53:59 2015 +0300

    Add company register number validation for Austria

diff --git a/stdnum/at/businessid.py b/stdnum/at/businessid.py
new file mode 100644
index 0000000..8ce5ab7
--- /dev/null
+++ b/stdnum/at/businessid.py
@@ -0,0 +1,70 @@
+# businessid.py - functions for handling Austrian company register numbers
+#
+# Copyright (C) 2015 Holvi Payment Services Oy
+# Copyright (C) 2012, 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
+
+"""Austrian Company Register Numbers.
+
+The Austrian company register number consist of digits followed by a single
+letter, e.g. "122119m". Sometimes it is presented with preceding "FN", e.g.
+"FN 122119m".
+
+>>> validate('FN 122119m')
+'122119m'
+>>> validate('122119m')
+'122119m'
+>>> validate('m123123')
+Traceback (most recent call last):
+    ...
+InvalidFormat: ...
+>>> validate('abc')
+Traceback (most recent call last):
+    ...
+InvalidFormat: ...
+"""
+
+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.
+    Preceding "FN" is also removed."""
+    number = clean(number, ' -./').strip()
+    if number.upper().startswith('FN'):
+        number = number[2:]
+    return number
+
+
+def validate(number):
+    """Checks to see if the number provided is a valid company register
+    number. This only checks the formatting."""
+    number = compact(number)
+    if not number[-1:].isalpha() or not number[:-1].isdigit():
+        raise InvalidFormat()
+    return number
+
+
+def is_valid(number):
+    """Checks to see if the number provided is a valid company register
+    number. This only checks the formatting."""
+    try:
+        return bool(validate(number))
+    except ValidationError:
+        return False

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

Summary of changes:
 stdnum/{de/vat.py => at/businessid.py} |   47 +++++++++++++++++---------------
 1 file changed, 25 insertions(+), 22 deletions(-)
 copy stdnum/{de/vat.py => at/businessid.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/