python-stdnum branch master updated. 1.1-17-gb939099
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.1-17-gb939099
- 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.1-17-gb939099
- Date: Sun, 16 Aug 2015 15:05:59 +0200 (CEST)
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 b93909974b29edb375523d9790068a5e364f3285 (commit)
via 7714db78b7e3b3d1f733dec455078bbd62a7cbb8 (commit)
via 6afa8757386fa4c4c8e0d369679c7e4b771458c6 (commit)
from e88ba0b7cb372e2d9bf56bb291ea5ed2f53de840 (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=b93909974b29edb375523d9790068a5e364f3285
commit b93909974b29edb375523d9790068a5e364f3285
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Aug 16 14:56:32 2015 +0200
Update IBAN tests
This updates the iban.dat file from the IBAN registry, includes a fix
for handling spaces in the BBAN and adds some more IBAN examples from
the IBAN registry.
diff --git a/getiban.py b/getiban.py
index 2b9bf98..e026293 100755
--- a/getiban.py
+++ b/getiban.py
@@ -2,7 +2,7 @@
# getiban.py - script to donwload and parse data from the IBAN registry
#
-# Copyright (C) 2011, 2013 Arthur de Jong
+# Copyright (C) 2011-2015 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
@@ -62,7 +62,7 @@ def parse(f):
bban = bban[5:]
# print country line
print '%s country="%s" bban="%s"' % (
- cc, row['name of country'], bban)
+ 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
diff --git a/stdnum/iban.dat b/stdnum/iban.dat
index 95ba5c4..1b873ff 100644
--- a/stdnum/iban.dat
+++ b/stdnum/iban.dat
@@ -53,6 +53,7 @@ PS country="Palestine, State of" bban="4!a21!c"
PL country="Poland" bban="8!n16!n"
PT country="Portugal" bban="4!n4!n11!n2!n"
QA country="Qatar" bban="4!a21!c"
+LC country="Saint Lucia" bban="4!a24n"
RO country="Romania" bban="4!a16!c"
SM country="San Marino" bban="1!a5!n5!n12!c"
SA country="Saudi Arabia" bban="2!n18!c"
@@ -62,7 +63,7 @@ SI country="Slovenia" bban="5!n8!n2!n"
ES country="Spain" bban="4!n4!n1!n1!n10!n"
SE country="Sweden" bban="3!n16!n1!n"
CH country="Switzerland" bban="5!n12!c"
-TL country="Timor-Leste" bban="3!n 14!n 2!n"
+TL country="Timor-Leste" bban="3!n14!n2!n"
TN country="Tunisia" bban="2!n3!n13!n2!n"
TR country="Turkey" bban="5!n1!n16!c"
AE country="United Arab Emirates" bban="3!n16!n"
diff --git a/tests/test_iban.doctest b/tests/test_iban.doctest
index 7847ec3..b2d91b8 100644
--- a/tests/test_iban.doctest
+++ b/tests/test_iban.doctest
@@ -1,6 +1,6 @@
test_iban.doctest - more detailed doctests for the stdnum.iban module
-Copyright (C) 2011 Arthur de Jong
+Copyright (C) 2011-2015 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
@@ -29,111 +29,128 @@ These should all be valid numbers and are from the IBAN
REGISTRY as sample
numbers:
>>> numbers = '''
-... AL47212110090000000235698741
+... AD12 0001 2030 2003 5910 0100
... AD1200012030200359100100
+... AE070331234567890123456
+... AL47 2121 1009 0000 0002 3569 8741
+... AL47212110090000000235698741
+... AT61 1904 3002 3457 3201
... AT611904300234573201
-... BE68539007547034
+... AZ21NABZ00000000137010001944
+... BA39 1290 0794 0102 8494
... BA391290079401028494
+... BE68 5390 0754 7034
+... BE68539007547034
+... BG80 BNBG 9661 1020 3456 78
... BG80BNBG96611020345678
-... HR1210010051863000160
+... BH67BMAG00001299123456
+... BR1800000000141455123924100C2
+... BR9700360305000010009795493P1
+... CH93 0076 2011 6238 5295 7
+... CH9300762011623852957
+... CR0515202001026284066
+... CY17 0020 0128 0000 0012 0052 7600
... CY17002001280000001200527600
+... CZ65 0800 0000 1920 0014 5399
... CZ6508000000192000145399
+... CZ94 5500 0000 0010 1103 8930
... CZ9455000000001011038930
+... DE89 3704 0044 0532 0130 00
+... DE89370400440532013000
+... DK50 0040 0440 1162 43
... DK5000400440116243
-... FO6264600001631634
-... GL8964710001000206
+... DO28BAGR00000001212453611324
+... EE38 2200 2210 2014 5685
... EE382200221020145685
+... ES91 2100 0418 4502 0005 1332
+... ES9121000418450200051332
+... FI21 1234 5600 0007 85
... FI2112345600000785
... FI5542345670000081
+... FO62 6460 0001 6316 34
+... FO6264600001631634
+... FR14 2004 1010 0505 0001 3M02 606
... FR1420041010050500013M02606
-... DE89370400440532013000
+... GB29 NWBK 6016 1331 9268 19
+... GB29NWBK60161331926819
+... GE29 NB00 0000 0101 9049 17
... GE29NB0000000101904917
+... GI75 NWBK 0000 0000 7099 453
... GI75NWBK000000007099453
+... GL89 6471 0001 0002 06
+... GL8964710001000206
+... GR16 0110 1250 0000 0001 2300 695
... GR1601101250000000012300695
+... GT82TRAJ01020000001210029690
+... HR12 1001 0051 8630 0016 0
+... HR1210010051863000160
+... HU42 1177 3016 1111 1018 0000 0000
... HU42117730161111101800000000
-... IS140159260076545510730339
+... IE29 AIBK 9311 5212 3456 78
... IE29AIBK93115212345678
+... IL62 0108 0000 0009 9999 999
... IL620108000000099999999
+... IS14 0159 2600 7654 5510 7303 39
+... IS140159260076545510730339
+... IT60 X054 2811 1010 0000 0123 456
... IT60X0542811101000000123456
-... LV80BANK0000435195001
+... JO94CBJO0010000000000131000302
+... KZ86125KZT5004100100
+... LB62 0999 0000 0001 0019 0122 9114
... LB62099900000001001901229114
+... LI21 0881 0000 2324 013A A
... LI21088100002324013AA
+... LT12 1000 0111 0100 1000
... LT121000011101001000
+... LU28 0019 4006 4475 0000
... LU280019400644750000
-... MK07250120000058984
-... MT84MALT011000012345MTLCAST001S
-... MR1300020001010000123456753
-... MU17 BOMM0101101030300200000MUR
+... LV80 BANK 0000 4351 9500 1
+... LV80BANK0000435195001
+... MC11 1273 9000 7000 1111 1000 h79
... MC1112739000700011111000h79
+... MD24AG000225100013104168
+... ME25 5050 0001 2345 6789 51
... ME25505000012345678951
-... NL91ABNA0417164300
-... NO9386011117947
-... PL61109010140000071219812874
-... PT50000201231234567890154
-... RO49AAAA1B31007593840000
-... SM86U0322509800000000270100
-... SA0380000000608010167519
-... RS35260005601001611379
-... SK3112000000198742637541
-... SI56191000000123438
-... ES9121000418450200051332
-... SE4550000000058398257466
-... CH9300762011623852957
-... TN5910006035183598478831
-... TR330006100519786457841326
-... GB29NWBK60161331926819
-... AL47 2121 1009 0000 0002 3569 8741
-... AD12 0001 2030 2003 5910 0100
-... AT61 1904 3002 3457 3201
-... BE68 5390 0754 7034
-... BA39 1290 0794 0102 8494
-... BG80 BNBG 9661 1020 3456 78
-... HR12 1001 0051 8630 0016 0
-... CY17 0020 0128 0000 0012 0052 7600
-... CZ65 0800 0000 1920 0014 5399
-... CZ94 5500 0000 0010 1103 8930
-... DK50 0040 0440 1162 43
-... FO62 6460 0001 6316 34
-... GL89 6471 0001 0002 06
-... EE38 2200 2210 2014 5685
-... FI21 1234 5600 0007 85
-... FR14 2004 1010 0505 0001 3M02 606
-... DE89 3704 0044 0532 0130 00
-... GE29 NB00 0000 0101 9049 17
-... GI75 NWBK 0000 0000 7099 453
-... GR16 0110 1250 0000 0001 2300 695
-... HU42 1177 3016 1111 1018 0000 0000
-... IS14 0159 2600 7654 5510 7303 39
-... IE29 AIBK 9311 5212 3456 78
-... IL62 0108 0000 0009 9999 999
-... IT60 X054 2811 1010 0000 0123 456
-... LV80 BANK 0000 4351 9500 1
-... LB62 0999 0000 0001 0019 0122 9114
-... LI21 0881 0000 2324 013A A
-... LT12 1000 0111 0100 1000
-... LU28 0019 4006 4475 0000
... MK072 5012 0000 0589 84
-... MT84 MALT 0110 0001 2345 MTLC AST0 01S
+... MK07250120000058984
... MR13 0002 0001 0100 0012 3456 753
+... MR1300020001010000123456753
+... MT84 MALT 0110 0001 2345 MTLC AST0 01S
+... MT84MALT011000012345MTLCAST001S
... MU17 BOMM 0101 1010 3030 0200 000M UR
-... MC11 1273 9000 7000 1111 1000 h79
-... ME25 5050 0001 2345 6789 51
+... MU17 BOMM0101101030300200000MUR
... NL91 ABNA 0417 1643 00
+... NL91ABNA0417164300
... NO93 8601 1117 947
+... NO9386011117947
+... PK36SCBL0000001123456702
... PL61 1090 1014 0000 0712 1981 2874
+... PL61109010140000071219812874
+... PS92PALS000000000400123456702
... PT50 0002 0123 1234 5678 9015 4
+... PT50000201231234567890154
+... QA58DOHB00001234567890ABCDEFG
... RO49 AAAA 1B31 0075 9384 0000
-... SM86 U032 2509 8000 0000 0270 100
-... SA03 8000 0000 6080 1016 7519
+... RO49AAAA1B31007593840000
... RS35 2600 0560 1001 6113 79
-... SK31 1200 0000 1987 4263 7541
-... SI56 1910 0000 0123 438
-... ES91 2100 0418 4502 0005 1332
+... RS35260005601001611379
+... SA03 8000 0000 6080 1016 7519
+... SA0380000000608010167519
... SE45 5000 0000 0583 9825 7466
-... CH93 0076 2011 6238 5295 7
+... SE4550000000058398257466
+... SI56 1910 0000 0123 438
+... SI56191000000123438
+... SK31 1200 0000 1987 4263 7541
+... SK3112000000198742637541
+... SM86 U032 2509 8000 0000 0270 100
+... SM86U0322509800000000270100
+... TL 38 008 00123456789101 57
... TN59 1000 6035 1835 9847 8831
+... TN5910006035183598478831
... TR33 0006 1005 1978 6457 8413 26
-... GB29 NWBK 6016 1331 9268 19
+... TR330006100519786457841326
+... VG96VPVG0000012345678901
+... XK051212012345678906
... '''
>>> [ x for x in numbers.splitlines() if x and not iban.is_valid(x) ]
[]
http://arthurdejong.org/git/python-stdnum/commit/?id=7714db78b7e3b3d1f733dec455078bbd62a7cbb8
commit 7714db78b7e3b3d1f733dec455078bbd62a7cbb8
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Aug 16 13:36:51 2015 +0200
Make uppercase in compact()
This changes the compact() function of the ISO 9362 module to make all
the letters uppercase.
diff --git a/stdnum/iso9362.py b/stdnum/iso9362.py
index e58ae52..7844617 100644
--- a/stdnum/iso9362.py
+++ b/stdnum/iso9362.py
@@ -49,14 +49,13 @@ import re
from stdnum.exceptions import *
from stdnum.util import clean
-_bic_re = re.compile(r'^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?$', re.IGNORECASE)
+_bic_re = re.compile(r'^[A-Z]{6}[0-9A-Z]{2}([0-9A-Z]{3})?$')
def compact(number):
"""Convert the number to the minimal representation. This strips the
number of any surrounding whitespace."""
- number = clean(number).strip()
- return number
+ return clean(number).strip().upper()
def validate(number):
@@ -82,5 +81,4 @@ def is_valid(number):
def format(number):
"""Reformat the passed number to the standard format."""
- number = compact(number)
- return number.upper()
+ return compact(number)
http://arthurdejong.org/git/python-stdnum/commit/?id=6afa8757386fa4c4c8e0d369679c7e4b771458c6
commit 6afa8757386fa4c4c8e0d369679c7e4b771458c6
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Aug 16 13:26:39 2015 +0200
Turn on and improve branch coverage
diff --git a/setup.cfg b/setup.cfg
index abf5bb2..106690c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,6 +7,7 @@ with-doctest=true
doctest-extension=doctest
doctest-options=+IGNORE_EXCEPTION_DETAIL
with-coverage=true
+cover-branches=true
cover-package=stdnum
cover-erase=true
cover-html=true
diff --git a/stdnum/imei.py b/stdnum/imei.py
index 1fad6c3..f4b9e90 100644
--- a/stdnum/imei.py
+++ b/stdnum/imei.py
@@ -76,7 +76,7 @@ def imei_type(number):
return None
if len(number) in (14, 15):
return 'IMEI'
- elif len(number) == 16:
+ else: # len(number) == 16:
return 'IMEISV'
diff --git a/stdnum/isbn.py b/stdnum/isbn.py
index 9b6c722..2bc2b6e 100644
--- a/stdnum/isbn.py
+++ b/stdnum/isbn.py
@@ -100,7 +100,7 @@ def isbn_type(number):
return None
if len(number) == 10:
return 'ISBN10'
- elif len(number) == 13:
+ else: # len(number) == 13:
return 'ISBN13'
diff --git a/stdnum/isil.py b/stdnum/isil.py
index b7024a9..b0ee905 100644
--- a/stdnum/isil.py
+++ b/stdnum/isil.py
@@ -37,6 +37,8 @@ Traceback (most recent call last):
InvalidLength: ...
>>> format('it-RM0267')
'IT-RM0267'
+>>> format('zz-RM0267') # unknown agencies are left alone
+'zz-RM0267'
"""
from stdnum.exceptions import *
diff --git a/stdnum/ismn.py b/stdnum/ismn.py
index a26d123..3de83f1 100644
--- a/stdnum/ismn.py
+++ b/stdnum/ismn.py
@@ -76,7 +76,7 @@ def ismn_type(number):
return None
if len(number) == 10:
return 'ISMN10'
- elif len(number) == 13:
+ else: # len(number) == 13:
return 'ISMN13'
diff --git a/stdnum/meid.py b/stdnum/meid.py
index 5d38608..418a929 100644
--- a/stdnum/meid.py
+++ b/stdnum/meid.py
@@ -26,6 +26,8 @@ CDMA mobile station equipment.
'AF0123450ABCDE'
>>> validate('29360 87365 0070 3710 0')
'AF0123450ABCDE'
+>>> validate('29360 87365 0070 3710 0', strip_check_digit=False)
+'AF0123450ABCDEC'
>>> validate('29360 87365 0070 3710 1')
Traceback (most recent call last):
...
diff --git a/stdnum/us/atin.py b/stdnum/us/atin.py
index b3218db..7068bb8 100644
--- a/stdnum/us/atin.py
+++ b/stdnum/us/atin.py
@@ -31,6 +31,8 @@ Traceback (most recent call last):
InvalidFormat: ...
>>> format('123456789')
'123-45-6789'
+>>> format('123') # unknown formatting is left alone
+'123'
"""
import re
diff --git a/stdnum/us/ein.py b/stdnum/us/ein.py
index ea63b9a..e40e7c6 100644
--- a/stdnum/us/ein.py
+++ b/stdnum/us/ein.py
@@ -38,6 +38,8 @@ Traceback (most recent call last):
InvalidComponent: ...
>>> format('042103594')
'04-2103594'
+>>> format('123') # unknown formatting is left alone
+'123'
"""
import re
diff --git a/stdnum/us/itin.py b/stdnum/us/itin.py
index bde97b7..6233e89 100644
--- a/stdnum/us/itin.py
+++ b/stdnum/us/itin.py
@@ -45,6 +45,8 @@ InvalidComponent: ...
'123456789'
>>> format('111223333')
'111-22-3333'
+>>> format('123') # unknown formatting is left alone
+'123'
"""
import re
-----------------------------------------------------------------------
Summary of changes:
getiban.py | 4 +-
setup.cfg | 1 +
stdnum/iban.dat | 3 +-
stdnum/imei.py | 2 +-
stdnum/isbn.py | 2 +-
stdnum/isil.py | 2 +
stdnum/ismn.py | 2 +-
stdnum/iso9362.py | 8 +--
stdnum/meid.py | 2 +
stdnum/us/atin.py | 2 +
stdnum/us/ein.py | 2 +
stdnum/us/itin.py | 2 +
tests/test_iban.doctest | 155 ++++++++++++++++++++++++++---------------------
13 files changed, 107 insertions(+), 80 deletions(-)
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/
- python-stdnum branch master updated. 1.1-17-gb939099,
Commits of the python-stdnum project