[Python-modules-commits] [python-stdnum] 01/03: Import python-stdnum_1.5.orig.tar.gz

Arthur de Jong adejong at moszumanska.debian.org
Sun Nov 13 22:57:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

adejong pushed a commit to branch master
in repository python-stdnum.

commit ec00083f98a864cdf9b1063dfeebb5701abb7c20
Author: Arthur de Jong <adejong at debian.org>
Date:   Sun Nov 13 23:30:37 2016 +0100

    Import python-stdnum_1.5.orig.tar.gz
---
 ChangeLog                                 | 214 ++++++++-
 NEWS                                      |  16 +
 PKG-INFO                                  |  11 +-
 README                                    |   9 +-
 docs/index.rst                            |   7 +
 docs/stdnum.au.abn.rst                    |   5 +
 docs/stdnum.au.acn.rst                    |   5 +
 docs/stdnum.au.tfn.rst                    |   5 +
 docs/stdnum.es.ccc.rst                    |   5 +
 docs/stdnum.es.cups.rst                   |   5 +
 docs/stdnum.es.iban.rst                   |   5 +
 docs/stdnum.es.referenciacatastral.rst    |   5 +
 getiban.py                                |  62 +--
 getisbn.py                                |  10 +-
 python_stdnum.egg-info/PKG-INFO           |  11 +-
 python_stdnum.egg-info/SOURCES.txt        |  20 +
 stdnum/__init__.py                        |  11 +-
 stdnum/{be => au}/__init__.py             |   6 +-
 stdnum/au/abn.py                          |  85 ++++
 stdnum/au/acn.py                          |  91 ++++
 stdnum/{be/vat.py => au/tfn.py}           |  61 ++-
 stdnum/be/__init__.py                     |   5 +-
 stdnum/be/vat.py                          |   8 +-
 stdnum/cn/loc.dat                         |   2 +-
 stdnum/es/ccc.py                          | 127 ++++++
 stdnum/es/cups.py                         | 113 +++++
 stdnum/es/iban.py                         |  79 ++++
 stdnum/es/referenciacatastral.py          | 118 +++++
 stdnum/eu/at_02.py                        |  26 +-
 stdnum/eu/vat.py                          |   6 +-
 stdnum/exceptions.py                      |   2 +-
 stdnum/iban.dat                           |  72 +--
 stdnum/iban.py                            |  58 ++-
 stdnum/imsi.dat                           | 723 ++++++++++++++++++------------
 stdnum/isbn.dat                           |  29 +-
 stdnum/isil.dat                           |   4 +-
 stdnum/numdb.py                           |   3 +-
 stdnum/util.py                            |  25 +-
 tests/test_au_abn.doctest                 | 136 ++++++
 tests/test_au_acn.doctest                 | 125 ++++++
 tests/test_au_tfn.doctest                 |  42 ++
 tests/test_es_cups.doctest                |  83 ++++
 tests/test_es_referenciacatastral.doctest | 295 ++++++++++++
 tests/test_iban.doctest                   |  37 +-
 44 files changed, 2294 insertions(+), 473 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 412b3ad..8ba0abc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,179 @@
+2016-11-13  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [c9beb00] stdnum/cn/loc.dat, stdnum/iban.dat, stdnum/imsi.dat,
+	  stdnum/isbn.dat, stdnum/isil.dat, tests/test_iban.doctest:
+	  Update database files
+
+	  This removes the Costa Rica IBAN test because the format of the
+	  IBAN seems to have been changed. The old length still seems to
+	  be in use so a more permanent solution is probably required.
+
+2016-11-13  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [ac560a7] getisbn.py: Update getisbn to Python3
+
+	  There were some SSL-related issues with the urllib module. This
+	  was the easiest solution.
+
+2016-11-13  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [458c310] getiban.py: Update gettin IBAN registry
+
+	  The format of the registry file has changed. Before it was a
+	  straightforward CSV file with countries in rows but countries
+	  are now in columns.
+
+2016-11-09  Sergi Almacellas Abellana <sergi at koolpi.com>
+
+	* [45faa7c] .gitignore, tox.ini: Add tox.ini file
+
+2016-11-08  Sergi Almacellas Abellana <sergi at koolpi.com>
+
+	* [a9e5405] stdnum/eu/at_02.py: Implement calc_check_digits in
+	  SEPA Identifier of the Creditor (AT-02)
+
+2016-10-14  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [8ea76ba] stdnum/au/tfn.py, tests/test_au_tfn.doctest: Add
+	  Australian Tax File Number
+
+	  Based on the implementation provided by Vincent Bastos
+	  <vincent at lavalab.com.au>
+
+	  See https://github.com/arthurdejong/python-stdnum/pull/40
+
+2016-10-14  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [8028c3a] stdnum/au/acn.py, tests/test_au_acn.doctest: Add
+	  Australian Company Number
+
+	  Based on the implementation provided by Vincent Bastos
+	  <vincent at lavalab.com.au>
+
+	  See https://github.com/arthurdejong/python-stdnum/pull/40
+
+2016-10-14  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [70b94ee] stdnum/au/__init__.py, stdnum/au/abn.py,
+	  tests/test_au_abn.doctest: Add Australian Business Number
+
+	  Based on the implementation provided by Vincent Bastos
+	  <vincent at lavalab.com.au>
+
+	  See https://github.com/arthurdejong/python-stdnum/pull/40
+
+2016-10-14  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [d7cff5d] stdnum/be/__init__.py, stdnum/be/vat.py: Provide
+	  businessid as an alias
+
+	  The Belgian company number or enterprise number
+	  (ondernemingsnummer) is the new name for what was previously
+	  the VAT number.
+
+2016-09-10  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [352aa8a] stdnum/es/referenciacatastral.py: Add reference to
+	  Referencia Catastral implementation
+
+2016-09-03  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [49db553] tests/test_es_referenciacatastral.doctest: Add more
+	  tests for Referencia Catastral
+
+	  This adds a number of extra tests for the Spanish Referencia
+	  Catastral (stdnum.es.referenciacatastral) module, mostly based
+	  on numbers found online.
+
+	  This commit includes some of the documentation on the structure
+	  of Referencia Catastral that was in the original pull request.
+
+	  See https://github.com/arthurdejong/python-stdnum/pull/38
+
+2016-08-31  David García Garzón <david.garcia at upf.edu>
+
+	* [2c557a0] stdnum/es/referenciacatastral.py: Add Spansih Referencia
+	  Catastral
+
+	  The control digit check algorithm is based on Javascript
+	  implementation by Vicente Sancho that can be found at
+	  http://trellat.es/validar-la-referencia-catastral-en-javascript/
+
+	  See https://github.com/arthurdejong/python-stdnum/pull/38
+
+2016-09-10  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [b128c8d] tests/test_iban.doctest: Test a few Spanish IBANs
+	  found online
+
+2016-09-10  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [878e036] stdnum/numdb.py: Avoid leaving open file descriptor
+	  in test
+
+2016-09-08  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [be24790] stdnum/es/iban.py, tests/test_iban.doctest: Add Spanish
+	  IBAN number module
+
+	  This validates the country-specific part of the IBAN.
+
+2016-09-08  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [2510932] stdnum/iban.py: Validate country-specific part of IBAN
+
+	  This adds the possible of validating the country-specific part
+	  of the IBAN. If the country has an IBAN module, checking is also
+	  delegated to that module.
+
+2016-09-06  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [d8cca82] stdnum/eu/vat.py, stdnum/util.py: Introduce
+	  get_cc_module() utility function
+
+	  This changes the get_vat_module() function to a more generic
+	  get_cc_module() function so that it can also be used for other
+	  things like IBAN checking.
+
+2016-09-06  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [1622873] stdnum/es/ccc.py: Add to_iban() function to Spanish CCC
+
+2016-09-08  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [7d969be] stdnum/iban.py: Implement calc_check_digits() in IBAN
+
+	  Introduce a function to calculate the two check digits of an
+	  IBAN. Since the check digits are the third and fourth characters
+	  in the number, placeholders need to be provided when calling
+	  this function.
+
+2016-08-31  David García Garzón <voki at canvoki.net>
+
+	* [294f872] stdnum/es/ccc.py: Add Spanish Código Cuenta Corriente
+	  (CCC)
+
+2016-08-28  David García Garzón <david.garcia at upf.edu>
+
+	* [466cec8] stdnum/es/cups.py, tests/test_es_cups.doctest: Add
+	  Spanish CUPS code
+
+2016-08-28  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [d95382f] stdnum/exceptions.py: Properly print error message
+	  of exceptions
+
+	  This ensures that the message passed to the constructor is shown
+	  in the traceback while falling back to the class default.
+
+2016-07-26  Arthur de Jong <arthur at arthurdejong.org>
+
+	* [01a7f34] ChangeLog, NEWS, README, docs/index.rst,
+	  docs/stdnum.damm.rst, docs/stdnum.fr.nif.rst,
+	  docs/stdnum.fr.nir.rst, docs/stdnum.fr.siret.rst,
+	  docs/stdnum.gb.nhs.rst, docs/stdnum.tr.tckimlik.rst,
+	  stdnum/__init__.py: Get files ready for 1.4 release
+
 2016-07-26  Arthur de Jong <arthur at arthurdejong.org>
 
 	* [3e4e9e2] getmybp.py, stdnum/cn/loc.dat, stdnum/iban.dat,
@@ -307,8 +483,8 @@ Jong <arthur at arthurdejong.org>
 
 2015-10-10  Arthur de Jong <arthur at arthurdejong.org>
 
-	* [ebb5c07] MANIFEST.in, numdb-test.dat, stdnum/numdb.py,
-	  tests/numdb-test.dat: Move numdb test file
+	* [ebb5c07] MANIFEST.in, stdnum/numdb.py, tests/numdb-test.dat:
+	  Move numdb test file
 
 	  This places the test database file in the tests directory.
 
@@ -881,8 +1057,8 @@ Jong <arthur at arthurdejong.org>
 	  http://www.citizensinformation.ie/en/social_welfare/irish_social_welfare_system/personal_public_service_number.html
 2014-02-06  Arthur de Jong <arthur at arthurdejong.org>
 
-	* [71d9837] stdnum/at_02.py, stdnum/eu/at_02.py: Rename AT-02
-	  module to stdnum.eu.at_02
+	* [71d9837] stdnum/eu/at_02.py: Rename AT-02 module to
+	  stdnum.eu.at_02
 
 2014-02-05  Sergi Almacellas Abellana <sergi at koolpi.com>
 
@@ -1583,8 +1759,7 @@ Jong <arthur at arthurdejong.org>
 
 2012-02-20  Arthur de Jong <arthur at arthurdejong.org>
 
-	* [680b7d1] numdb-test.dat, stdnum/numdb.py, test.dat: rename
-	  numdb test file
+	* [680b7d1] numdb-test.dat, stdnum/numdb.py: rename numdb test file
 
 2012-02-20  Arthur de Jong <arthur at arthurdejong.org>
 
@@ -2133,13 +2308,13 @@ Jong <arthur at arthurdejong.org>
 
 2011-02-05  Arthur de Jong <arthur at arthurdejong.org>
 
-	* [62aa496] tests/test_br_cpf.doctest, tests/test_iban.doctest,
-	  tests/test_imei.doctest, tests/test_isan.doctest,
-	  tests/test_isbn.doctest, tests/test_ismn.doctest,
-	  tests/test_issn.doctest, tests/test_luhn.doctest,
-	  tests/test_meid.doctest, tests/test_nl_bsn.doctest,
-	  tests/test_robustness.doctest, tests/test_verhoeff.doctest:
-	  move all robustness tests into one test file
+	* [62aa496] tests/test_iban.doctest, tests/test_imei.doctest,
+	  tests/test_isan.doctest, tests/test_isbn.doctest,
+	  tests/test_ismn.doctest, tests/test_issn.doctest,
+	  tests/test_luhn.doctest, tests/test_meid.doctest,
+	  tests/test_nl_bsn.doctest, tests/test_robustness.doctest,
+	  tests/test_verhoeff.doctest: move all robustness tests into one
+	  test file
 
 2011-02-05  Arthur de Jong <arthur at arthurdejong.org>
 
@@ -2207,9 +2382,8 @@ Jong <arthur at arthurdejong.org>
 
 2011-01-15  Arthur de Jong <arthur at arthurdejong.org>
 
-	* [8d3a92c] stdnum/bsn.py, stdnum/nl/__init__.py, stdnum/nl/bsn.py,
-	  tests/test_bsn.doctest, tests/test_nl_bsn.doctest: move bsn
-	  module inside nl package
+	* [8d3a92c] stdnum/nl/__init__.py, stdnum/nl/bsn.py,
+	  tests/test_nl_bsn.doctest: move bsn module inside nl package
 
 2010-11-26  Arthur de Jong <arthur at arthurdejong.org>
 
@@ -2219,10 +2393,10 @@ Jong <arthur at arthurdejong.org>
 2010-11-24  Arthur de Jong <arthur at arthurdejong.org>
 
 	* [124c16d] getisbn.py, stdnum/isbn.dat, stdnum/isbn.py,
-	  stdnum/isbn/__init__.py, stdnum/isbn/ranges.py, stdnum/numdb.py,
-	  test.dat, tests/test_isbn.doctest: implement a new numdb module
-	  to hold information on hierarchically organised numbers and
-	  switch the isbn module to use this format instead
+	  stdnum/isbn/ranges.py, stdnum/numdb.py, test.dat,
+	  tests/test_isbn.doctest: implement a new numdb module to hold
+	  information on hierarchically organised numbers and switch the
+	  isbn module to use this format instead
 
 2010-09-11  Arthur de Jong <arthur at arthurdejong.org>
 
diff --git a/NEWS b/NEWS
index 1f8261d..317f8bb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,19 @@
+changes from 1.4 to 1.5
+-----------------------
+
+* add modules for the following number formats:
+  - ABN (Australian Business Number)
+  - ACN (Australian Company Number)
+  - TFN (Australian Tax File Number)
+  - CCC (Código Cuenta Corriente, Spanish Bank Account Code)
+  - CUPS (Código Unificado de Punto de Suministro, Supply Point Unified Code)
+  - Spanish IBAN (International Bank Account Number)
+  - Referencia Catastral (Spanish real estate property id)
+* The IBAN module now support validating the country-specific part
+* The Belgian VAT number is now also referenced as businessid
+* add a Tox configuration file
+
+
 changes from 1.3 to 1.4
 -----------------------
 
diff --git a/PKG-INFO b/PKG-INFO
index de3fdb0..a2bcf9d 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: python-stdnum
-Version: 1.4
+Version: 1.5
 Summary: Python module to handle standardized numbers and codes
 Home-page: http://arthurdejong.org/python-stdnum/
 Author: Arthur de Jong
@@ -17,7 +17,10 @@ Description: Parse, validate and reformat standard numbers and codes.
         * ar.cuit: CUIT (Código Único de Identificación Tributaria, Argentinian tax number)
         * at.businessid: Austrian Company Register Numbers
         * at.uid: UID (Umsatzsteuer-Identifikationsnummer, Austrian VAT number)
-        * be.vat: BTW, TVA, NWSt (Belgian VAT number)
+        * au.abn: ABN (Australian Business Number)
+        * au.acn: ACN (Australian Company Number)
+        * au.tfn: TFN (Australian Tax File Number)
+        * be.vat: BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number)
         * bg.egn: EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
         * bg.pnf: PNF (ЛНЧ, Личен номер на чужденец, Bulgarian number of a foreigner)
         * bg.vat: VAT (Идентификационен номер по ДДС, Bulgarian VAT number)
@@ -44,10 +47,14 @@ Description: Parse, validate and reformat standard numbers and codes.
         * ec.ruc: RUC (Registro Único de Contribuyentes, Ecuadorian company tax number)
         * ee.ik: Isikukood (Estonian Personcal ID number)
         * ee.kmkr: KMKR (Käibemaksukohuslase, Estonian VAT number)
+        * es.ccc: CCC (Código Cuenta Corriente, Spanish Bank Account Code)
         * es.cif: CIF (Certificado de Identificación Fiscal, Spanish company tax number)
+        * es.cups: CUPS (Código Unificado de Punto de Suministro, Supply Point Unified Code)
         * es.dni: DNI (Documento nacional de identidad, Spanish personal identity codes)
+        * es.iban: Spanish IBAN (International Bank Account Number)
         * es.nie: NIE (Número de Identificación de Extranjeros, Spanish foreigner number)
         * es.nif: NIF (Número de Identificación Fiscal, Spanish VAT number)
+        * es.referenciacatastral: Referencia Catastral (Spanish real estate property id)
         * eu.at_02: SEPA Identifier of the Creditor (AT-02)
         * eu.vat: VAT (European Union VAT number)
         * fi.alv: ALV nro (Arvonlisäveronumero, Finnish VAT number)
diff --git a/README b/README
index 4c8c8de..0cfdab8 100644
--- a/README
+++ b/README
@@ -13,7 +13,10 @@ Currently this package supports the following formats:
  * CUIT (Código Único de Identificación Tributaria, Argentinian tax number)
  * Austrian Company Register Numbers
  * UID (Umsatzsteuer-Identifikationsnummer, Austrian VAT number)
- * BTW, TVA, NWSt (Belgian VAT number)
+ * ABN (Australian Business Number)
+ * ACN (Australian Company Number)
+ * TFN (Australian Tax File Number)
+ * BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number)
  * EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
  * PNF (ЛНЧ, Личен номер на чужденец, Bulgarian number of a foreigner)
  * VAT (Идентификационен номер по ДДС, Bulgarian VAT number)
@@ -40,10 +43,14 @@ Currently this package supports the following formats:
  * RUC (Registro Único de Contribuyentes, Ecuadorian company tax number)
  * Isikukood (Estonian Personcal ID number)
  * KMKR (Käibemaksukohuslase, Estonian VAT number)
+ * CCC (Código Cuenta Corriente, Spanish Bank Account Code)
  * CIF (Certificado de Identificación Fiscal, Spanish company tax number)
+ * CUPS (Código Unificado de Punto de Suministro, Supply Point Unified Code)
  * DNI (Documento nacional de identidad, Spanish personal identity codes)
+ * Spanish IBAN (International Bank Account Number)
  * NIE (Número de Identificación de Extranjeros, Spanish foreigner number)
  * NIF (Número de Identificación Fiscal, Spanish VAT number)
+ * Referencia Catastral (Spanish real estate property id)
  * SEPA Identifier of the Creditor (AT-02)
  * VAT (European Union VAT number)
  * ALV nro (Arvonlisäveronumero, Finnish VAT number)
diff --git a/docs/index.rst b/docs/index.rst
index b85a8e0..3e4096f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -90,6 +90,9 @@ Available formats
    ar.cuit
    at.businessid
    at.uid
+   au.abn
+   au.acn
+   au.tfn
    be.vat
    bg.egn
    bg.pnf
@@ -117,10 +120,14 @@ Available formats
    ec.ruc
    ee.ik
    ee.kmkr
+   es.ccc
    es.cif
+   es.cups
    es.dni
+   es.iban
    es.nie
    es.nif
+   es.referenciacatastral
    eu.at_02
    eu.vat
    fi.alv
diff --git a/docs/stdnum.au.abn.rst b/docs/stdnum.au.abn.rst
new file mode 100644
index 0000000..e1b646a
--- /dev/null
+++ b/docs/stdnum.au.abn.rst
@@ -0,0 +1,5 @@
+stdnum.au.abn
+=============
+
+.. automodule:: stdnum.au.abn
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.au.acn.rst b/docs/stdnum.au.acn.rst
new file mode 100644
index 0000000..9b35a0a
--- /dev/null
+++ b/docs/stdnum.au.acn.rst
@@ -0,0 +1,5 @@
+stdnum.au.acn
+=============
+
+.. automodule:: stdnum.au.acn
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.au.tfn.rst b/docs/stdnum.au.tfn.rst
new file mode 100644
index 0000000..a010db8
--- /dev/null
+++ b/docs/stdnum.au.tfn.rst
@@ -0,0 +1,5 @@
+stdnum.au.tfn
+=============
+
+.. automodule:: stdnum.au.tfn
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.es.ccc.rst b/docs/stdnum.es.ccc.rst
new file mode 100644
index 0000000..75c830a
--- /dev/null
+++ b/docs/stdnum.es.ccc.rst
@@ -0,0 +1,5 @@
+stdnum.es.ccc
+=============
+
+.. automodule:: stdnum.es.ccc
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.es.cups.rst b/docs/stdnum.es.cups.rst
new file mode 100644
index 0000000..2fb2023
--- /dev/null
+++ b/docs/stdnum.es.cups.rst
@@ -0,0 +1,5 @@
+stdnum.es.cups
+==============
+
+.. automodule:: stdnum.es.cups
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.es.iban.rst b/docs/stdnum.es.iban.rst
new file mode 100644
index 0000000..6811e2c
--- /dev/null
+++ b/docs/stdnum.es.iban.rst
@@ -0,0 +1,5 @@
+stdnum.es.iban
+==============
+
+.. automodule:: stdnum.es.iban
+   :members:
\ No newline at end of file
diff --git a/docs/stdnum.es.referenciacatastral.rst b/docs/stdnum.es.referenciacatastral.rst
new file mode 100644
index 0000000..c77588f
--- /dev/null
+++ b/docs/stdnum.es.referenciacatastral.rst
@@ -0,0 +1,5 @@
+stdnum.es.referenciacatastral
+=============================
+
+.. automodule:: stdnum.es.referenciacatastral
+   :members:
\ No newline at end of file
diff --git a/getiban.py b/getiban.py
index 44d9f19..e6894c6 100755
--- a/getiban.py
+++ b/getiban.py
@@ -23,54 +23,56 @@
 Financial Telecommunication which is the official IBAN registrar) to get
 the data needed to correctly parse and validate IBANs."""
 
+from collections import defaultdict
 import csv
 import urllib
 
 
-# The place where the current version of IBAN_Registry.txt can be downloaded.
+# The place where the current version of
+# swift_standards_infopaper_ibanregistry_1.txt can be downloaded.
 download_url = 'https://www.swift.com/node/11971'
 
 
-def clean_row(row):
-    """Clean up a read row from the CSV file."""
-    stripit = ' \t\n\r;:\'"'
-    return dict(
-        (k.strip(stripit).lower(), v.strip(stripit))
-        for k, v in row.items())
-
-
 def get_country_codes(line):
     """Return the list of country codes this line has."""
     # simplest case first
-    if len(line['country code as defined in iso 3166']) == 2:
-        return [line['country code as defined in iso 3166']]
+    if len(line['IBAN prefix country code (ISO 3166)']) == 2:
+        return [line['IBAN prefix country code (ISO 3166)']]
     # fall back to parsing the IBAN structure
     return [x.strip()[:2] for x in line['iban structure'].split(',')]
 
 
 def parse(f):
     """Parse the specified file."""
-    print '# generated from IBAN_Registry.txt, downloaded from'
-    print '# %s' % download_url
-    for row in csv.DictReader(f, delimiter='\t', quotechar='"'):
-        row = clean_row(row)
-        bban = row['bban structure']
-        if not(bban) or bban.lower() == 'not in use':
-            bban = row['iban structure']
-        for cc in get_country_codes(row):
-            if bban.startswith(cc + '2!n'):
-                bban = bban[5:]
-            # print country line
-            print '%s country="%s" bban="%s"' % (
-                cc, row['name of country'], bban.replace(' ', ''))
-            # TODO: some countries have a fixed check digit value
-            # TODO: some countries have extra check digits
-            # TODO: use "Bank identifier position within the BBAN" field
-            #       to add labels to the ranges (Bank identifier and Branch
-            #       Identifier)
+    print '# generated from swift_standards_infopaper_ibanregistry_1.txt,'
+    print '# downloaded from %s' % download_url
+    values = defaultdict(dict)
+    # the file is CSV but the data is in columns instead of rows
+    for row in csv.reader(f, delimiter='\t', quotechar='"'):
+        # skip first row
+        if row[0] != 'Data element':
+            # first column contains label
+            for i, c in enumerate(row[1:]):
+                values[i][row[0]] = c
+    # output the collected data
+    for i, data in values.items():
+        bban = data['BBAN structure']
+        if not(bban) or bban.lower() == 'n/a':
+            bban = data['IBAN structure']
+        bban = bban.replace(' ', '')
+        cc = data['IBAN prefix country code (ISO 3166)'][:2]
+        cname = data['Name of country']
+        if bban.startswith(cc + '2!n'):
+            bban = bban[5:]
+        # print country line
+        print '%s country="%s" bban="%s"' % (cc, cname, bban)
+        # TODO: some countries have a fixed check digit value
+        # TODO: some countries have extra check digits
+        # TODO: use "Bank identifier position within the BBAN" field
+        #       to add labels to the ranges (Bank identifier and Branch
+        #       Identifier)
 
 
 if __name__ == '__main__':
-    #f = open('IBAN_Registry.txt', 'r')
     f = urllib.urlopen(download_url)
     parse(f)
diff --git a/getisbn.py b/getisbn.py
index 5377565..5755df5 100755
--- a/getisbn.py
+++ b/getisbn.py
@@ -1,8 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # getisbn.py - script to get ISBN prefix data
 #
-# Copyright (C) 2010, 2011, 2014 Arthur de Jong
+# Copyright (C) 2010-2016 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
@@ -26,7 +26,7 @@ to correctly split ISBNs into an EAN.UCC prefix, a group prefix, a registrant,
 an item number and a check-digit."""
 
 from xml.etree import ElementTree
-import urllib
+import urllib.request
 
 
 # the location of the ISBN Ranges XML file
@@ -55,7 +55,7 @@ def get(f=None):
     if f is None:
         yield '# generated from RangeMessage.xml, downloaded from'
         yield '# %s' % download_url
-        f = urllib.urlopen(download_url)
+        f = urllib.request.urlopen(download_url)
     else:
         yield '# generated from %r' % f
 
@@ -87,4 +87,4 @@ def get(f=None):
 if __name__ == '__main__':
     # get('RangeMessage.xml')
     for row in get():
-        print row.encode('utf-8')
+        print(row)
diff --git a/python_stdnum.egg-info/PKG-INFO b/python_stdnum.egg-info/PKG-INFO
index de3fdb0..a2bcf9d 100644
--- a/python_stdnum.egg-info/PKG-INFO
+++ b/python_stdnum.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: python-stdnum
-Version: 1.4
+Version: 1.5
 Summary: Python module to handle standardized numbers and codes
 Home-page: http://arthurdejong.org/python-stdnum/
 Author: Arthur de Jong
@@ -17,7 +17,10 @@ Description: Parse, validate and reformat standard numbers and codes.
         * ar.cuit: CUIT (Código Único de Identificación Tributaria, Argentinian tax number)
         * at.businessid: Austrian Company Register Numbers
         * at.uid: UID (Umsatzsteuer-Identifikationsnummer, Austrian VAT number)
-        * be.vat: BTW, TVA, NWSt (Belgian VAT number)
+        * au.abn: ABN (Australian Business Number)
+        * au.acn: ACN (Australian Company Number)
+        * au.tfn: TFN (Australian Tax File Number)
+        * be.vat: BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number)
         * bg.egn: EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
         * bg.pnf: PNF (ЛНЧ, Личен номер на чужденец, Bulgarian number of a foreigner)
         * bg.vat: VAT (Идентификационен номер по ДДС, Bulgarian VAT number)
@@ -44,10 +47,14 @@ Description: Parse, validate and reformat standard numbers and codes.
         * ec.ruc: RUC (Registro Único de Contribuyentes, Ecuadorian company tax number)
         * ee.ik: Isikukood (Estonian Personcal ID number)
         * ee.kmkr: KMKR (Käibemaksukohuslase, Estonian VAT number)
+        * es.ccc: CCC (Código Cuenta Corriente, Spanish Bank Account Code)
         * es.cif: CIF (Certificado de Identificación Fiscal, Spanish company tax number)
+        * es.cups: CUPS (Código Unificado de Punto de Suministro, Supply Point Unified Code)
         * es.dni: DNI (Documento nacional de identidad, Spanish personal identity codes)
+        * es.iban: Spanish IBAN (International Bank Account Number)
         * es.nie: NIE (Número de Identificación de Extranjeros, Spanish foreigner number)
         * es.nif: NIF (Número de Identificación Fiscal, Spanish VAT number)
+        * es.referenciacatastral: Referencia Catastral (Spanish real estate property id)
         * eu.at_02: SEPA Identifier of the Creditor (AT-02)
         * eu.vat: VAT (European Union VAT number)
         * fi.alv: ALV nro (Arvonlisäveronumero, Finnish VAT number)
diff --git a/python_stdnum.egg-info/SOURCES.txt b/python_stdnum.egg-info/SOURCES.txt
index b0a30a0..670485d 100644
--- a/python_stdnum.egg-info/SOURCES.txt
+++ b/python_stdnum.egg-info/SOURCES.txt
@@ -20,6 +20,9 @@ docs/stdnum.al.nipt.rst
 docs/stdnum.ar.cuit.rst
 docs/stdnum.at.businessid.rst
 docs/stdnum.at.uid.rst
+docs/stdnum.au.abn.rst
+docs/stdnum.au.acn.rst
+docs/stdnum.au.tfn.rst
 docs/stdnum.be.vat.rst
 docs/stdnum.bg.egn.rst
 docs/stdnum.bg.pnf.rst
@@ -48,10 +51,14 @@ docs/stdnum.ec.ci.rst
 docs/stdnum.ec.ruc.rst
 docs/stdnum.ee.ik.rst
 docs/stdnum.ee.kmkr.rst
+docs/stdnum.es.ccc.rst
 docs/stdnum.es.cif.rst
+docs/stdnum.es.cups.rst
 docs/stdnum.es.dni.rst
+docs/stdnum.es.iban.rst
 docs/stdnum.es.nie.rst
 docs/stdnum.es.nif.rst
+docs/stdnum.es.referenciacatastral.rst
 docs/stdnum.eu.at_02.rst
 docs/stdnum.eu.vat.rst
 docs/stdnum.exceptions.rst
@@ -167,6 +174,10 @@ stdnum/ar/cuit.py
 stdnum/at/__init__.py
 stdnum/at/businessid.py
 stdnum/at/uid.py
+stdnum/au/__init__.py
+stdnum/au/abn.py
+stdnum/au/acn.py
+stdnum/au/tfn.py
 stdnum/be/__init__.py
 stdnum/be/vat.py
 stdnum/bg/__init__.py
@@ -208,10 +219,14 @@ stdnum/ee/__init__.py
 stdnum/ee/ik.py
 stdnum/ee/kmkr.py
 stdnum/es/__init__.py
+stdnum/es/ccc.py
 stdnum/es/cif.py
+stdnum/es/cups.py
 stdnum/es/dni.py
+stdnum/es/iban.py
 stdnum/es/nie.py
 stdnum/es/nif.py
+stdnum/es/referenciacatastral.py
 stdnum/eu/__init__.py
 stdnum/eu/at_02.py
 stdnum/eu/vat.py
@@ -308,6 +323,9 @@ stdnum/us/tin.py
 tests/numdb-test.dat
 tests/test_al_nipt.doctest
 tests/test_ar_cuit.doctest
+tests/test_au_abn.doctest
+tests/test_au_acn.doctest
+tests/test_au_tfn.doctest
 tests/test_bg_vat.doctest
 tests/test_br_cnpj.doctest
 tests/test_ch_ssn.doctest
@@ -325,6 +343,8 @@ tests/test_ean.doctest
 tests/test_ec_ci.doctest
 tests/test_ec_ruc.doctest
 tests/test_ee_ik.doctest
+tests/test_es_cups.doctest
+tests/test_es_referenciacatastral.doctest
 tests/test_eu_vat.doctest
 tests/test_fi_hetu.doctest
 tests/test_fr_siren.doctest
diff --git a/stdnum/__init__.py b/stdnum/__init__.py
index d12dcd4..777a09b 100644
--- a/stdnum/__init__.py
+++ b/stdnum/__init__.py
@@ -29,7 +29,10 @@ Currently this package supports the following formats:
 * ar.cuit: CUIT (Código Único de Identificación Tributaria, Argentinian tax number)
 * at.businessid: Austrian Company Register Numbers
 * at.uid: UID (Umsatzsteuer-Identifikationsnummer, Austrian VAT number)
-* be.vat: BTW, TVA, NWSt (Belgian VAT number)
+* au.abn: ABN (Australian Business Number)
+* au.acn: ACN (Australian Company Number)
+* au.tfn: TFN (Australian Tax File Number)
+* be.vat: BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number)
 * bg.egn: EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes)
 * bg.pnf: PNF (ЛНЧ, Личен номер на чужденец, Bulgarian number of a foreigner)
 * bg.vat: VAT (Идентификационен номер по ДДС, Bulgarian VAT number)
@@ -56,10 +59,14 @@ Currently this package supports the following formats:
 * ec.ruc: RUC (Registro Único de Contribuyentes, Ecuadorian company tax number)
 * ee.ik: Isikukood (Estonian Personcal ID number)
 * ee.kmkr: KMKR (Käibemaksukohuslase, Estonian VAT number)
+* es.ccc: CCC (Código Cuenta Corriente, Spanish Bank Account Code)
 * es.cif: CIF (Certificado de Identificación Fiscal, Spanish company tax number)
+* es.cups: CUPS (Código Unificado de Punto de Suministro, Supply Point Unified Code)
 * es.dni: DNI (Documento nacional de identidad, Spanish personal identity codes)
+* es.iban: Spanish IBAN (International Bank Account Number)
 * es.nie: NIE (Número de Identificación de Extranjeros, Spanish foreigner number)
 * es.nif: NIF (Número de Identificación Fiscal, Spanish VAT number)
+* es.referenciacatastral: Referencia Catastral (Spanish real estate property id)
 * eu.at_02: SEPA Identifier of the Creditor (AT-02)
 * eu.vat: VAT (European Union VAT number)
 * fi.alv: ALV nro (Arvonlisäveronumero, Finnish VAT number)
@@ -159,4 +166,4 @@ parsing, validation, formatting or conversion functions.
 
 
 # the version number of the library
-__version__ = '1.4'
+__version__ = '1.5'
diff --git a/stdnum/be/__init__.py b/stdnum/au/__init__.py
similarity index 85%
copy from stdnum/be/__init__.py
copy to stdnum/au/__init__.py
index dd18378..bcf9b0b 100644
--- a/stdnum/be/__init__.py
+++ b/stdnum/au/__init__.py
@@ -1,7 +1,7 @@
-# __init__.py - collection of Belgian numbers
+# __init__.py - collection of Australian numbers
 # coding: utf-8
 #
-# Copyright (C) 2012 Arthur de Jong
+# Copyright (C) 2016 Vincent Bastos
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -18,4 +18,4 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-"""Collection of Belgian numbers."""
+"""Collection of Australian numbers."""
diff --git a/stdnum/au/abn.py b/stdnum/au/abn.py
new file mode 100644
index 0000000..ba69557
--- /dev/null
+++ b/stdnum/au/abn.py
@@ -0,0 +1,85 @@
+# abn.py - functions for handling Australian Business Numbers (ABNs)
+#
+# Copyright (C) 2016 Vincent Bastos
+# Copyright (C) 2016 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
+
+"""ABN (Australian Business Number).
+
+The Australian Business Number (ABN) is an identifier issued to entities
+registered in the Australian Business Register (ABR). The number consists of
+11 digits of which the first two are check digits.
+
+More information:
+
+* https://en.wikipedia.org/wiki/Australian_Business_Number
+* https://abr.business.gov.au/
+
+>>> validate('83 914 571 673')
+'83914571673'
+>>> validate('99 999 999 999')
+Traceback (most recent call last):
+    ...
+InvalidChecksum: ...
+>>> format('51824753556')
+'51 824 753 556'
+"""
+
+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 calc_check_digits(number):
+    """Calculate the check digits that should be prepended to make the number
+    valid."""
+    weights = (3, 5, 7, 9, 11, 13, 15, 17, 19)
+    s = sum(-w * int(n) for w, n in zip(weights, number))
+    return str(11 + (s - 1) % 89)
+
+
+def validate(number):
+    """Checks to see if the number provided is a valid ABN. This checks the
+    length, formatting and check digit."""
+    number = compact(number)
+    if not number.isdigit():
+        raise InvalidFormat()
+    if len(number) != 11:
+        raise InvalidLength()
+    if calc_check_digits(number[2:]) != number[:2]:
+        raise InvalidChecksum()
+    return number
+
+
+def is_valid(number):
+    """Checks to see if the number provided is a valid ABN. This checks the
+    length, formatting and check digit."""
+    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[0:2], number[2:5], number[5:8], number[8:]))
diff --git a/stdnum/au/acn.py b/stdnum/au/acn.py
new file mode 100644
index 0000000..ed99d3d
--- /dev/null
+++ b/stdnum/au/acn.py
@@ -0,0 +1,91 @@
+# acn.py - functions for handling Australian Company Numbers (ACNs)
+#
+# Copyright (C) 2016 Vincent Bastos
+# Copyright (C) 2016 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
+
+"""ACN (Australian Company Number).
+
+The Australian Company Number (ACN) is a company identifier issued by the
+Australian Securities and Investments Commission.
+
+More information:
+
+* https://en.wikipedia.org/wiki/Australian_Company_Number
+
+>>> validate('004 085 616')
+'004085616'
+>>> validate('010 499 966')
+'010499966'
+>>> validate('999 999 999')
+Traceback (most recent call last):
+    ...
+InvalidChecksum: ...
+>>> format('004085616')
+'004 085 616'
+>>> to_abn('002 724 334')
+'43002724334'
+"""
+
+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 calc_check_digit(number):
+    """Calculate the checksum."""
+    return str((sum(int(n) * (i - 8) for i, n in enumerate(number))) % 10)
+
+
+def validate(number):
+    """Checks to see if the number provided is a valid ACN. This checks the
+    length, formatting and check digit."""
+    number = compact(number)
+    if not number.isdigit():
+        raise InvalidFormat()
+    if len(number) != 9:
+        raise InvalidLength()
+    if calc_check_digit(number) != number[-1]:
+        raise InvalidChecksum()
+    return number
+
+
+def is_valid(number):
+    """Checks to see if the number provided is a valid ACN. This checks the
+    length, formatting and check digit."""
+    try:
+        return bool(validate(number))
+    except ValidationError:
... 3633 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-stdnum.git



More information about the Python-modules-commits mailing list