lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.17-49-g1364e19

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

python-stdnum branch master updated. 1.17-49-g1364e19



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  1364e1917750b1515cb1b1662c24bc1080c4ecbf (commit)
      from  f9728949cd1477868b656c2583f2568c6c28dce7 (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 -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=1364e1917750b1515cb1b1662c24bc1080c4ecbf

commit 1364e1917750b1515cb1b1662c24bc1080c4ecbf
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sat Nov 12 15:55:35 2022 +0100

    Support "I" and "O" in CUSIP number
    
    It is unclear why these letters were considered invalid at the time of
    the implementation.
    
    This also reduces the test set a bit while still covering most cases.
    
    Closes https://github.com/arthurdejong/python-stdnum/issues/337

diff --git a/stdnum/cusip.py b/stdnum/cusip.py
index ae69e6a..feaad0c 100644
--- a/stdnum/cusip.py
+++ b/stdnum/cusip.py
@@ -1,6 +1,6 @@
 # cusip.py - functions for handling CUSIP numbers
 #
-# Copyright (C) 2015-2017 Arthur de Jong
+# Copyright (C) 2015-2022 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
@@ -49,8 +49,7 @@ def compact(number):
     return clean(number, ' ').strip().upper()
 
 
-# O and I are not valid but are accounted for in the check digit calculation
-_alphabet = '0123456789ABCDEFGH JKLMN PQRSTUVWXYZ*@#'
+_alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#'
 
 
 def calc_check_digit(number):
diff --git a/tests/test_cusip.doctest b/tests/test_cusip.doctest
index 7ee1acb..9f97046 100644
--- a/tests/test_cusip.doctest
+++ b/tests/test_cusip.doctest
@@ -1,6 +1,6 @@
 test_cusip.doctest - more detailed doctests for the stdnum.cusip module
 
-Copyright (C) 2015 Arthur de Jong
+Copyright (C) 2015-2022 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
@@ -25,223 +25,119 @@ tries to validate a number of numbers that have been 
found online.
 >>> from stdnum.exceptions import *
 
 
-Number should not use O (capital o) or I (capital 1) to avoid confusion with
+Previously it was thought that O (capital o) or I (capital 1) were not allowed 
but
+apparently
 0 and 1:
 
->>> cusip.validate('0O141T575')
-Traceback (most recent call last):
-    ...
-InvalidFormat: ...
->>> cusip.validate('257I32103')
-Traceback (most recent call last):
-    ...
-InvalidFormat: ...
+>>> cusip.validate('FDIC90903')
+'FDIC90903'
 
 
 These have been found online and should all be valid numbers.
 
 >>> numbers = '''
 ...
-... 00078H125
-... 00080Y348
-... 00141H409
-... 00141M572
-... 00141T577
 ... 00141V267
-... 00142F832
 ... 00142K500
-... 00170J862
-... 00170K109
 ... 00170M873
 ... 00758M261
 ... 024524746
-... 024932808
 ... 024934408
 ... 025081704
-... 025081860
-... 02631C817
 ... 068278704
 ... 068278878
-... 06828M405
 ... 101156602
-... 119804102
-... 12628J600
 ... 140543828
 ... 192476109
-... 19765J830
-... 19765N401
-... 19765Y852
 ... 207267105
 ... 23336W809
 ... 23337G134
-... 23337R502
-... 23338F713
-... 245908660
-... 245917505
 ... 24610B859
 ... 25155T528
 ... 25156A668
 ... 25157M778
-... 25159K309
-... 25159L745
 ... 25264S403
 ... 254939424
-... 257132100
-... 258618701
-... 261967103
 ... 261967822
 ... 261986566
 ... 265458513
 ... 265458570
 ... 269858817
-... 277902565
-... 277905436
 ... 29372R208
 ... 313923302
-... 314172743
-... 315792598
-... 315805325
-... 315807651
 ... 315911875
 ... 315920579
-... 316069103
-... 31607A208
-... 316146257
-... 316175850
-... 31638R204
-... 316390277
-... 316390335
 ... 316390640
-... 316390681
 ... 320600109
-... 320604606
 ... 320917107
-... 353496854
-... 353535107
 ... 354128704
 ... 354723769
-... 36158T506
 ... 409902624
 ... 416649507
-... 416649606
 ... 425888104
-... 42588P825
-... 42588P882
-... 44929K630
 ... 461418691
 ... 465898682
 ... 469785109
 ... 471023531
 ... 47803M663
-... 4812A4427
 ... 4812C0548
-... 52106N335
 ... 52106N442
-... 52106N632
-... 52106N657
 ... 543912604
-... 543913305
-... 552984601
-... 552986309
-... 552986853
-... 557492428
 ... 56063J849
-... 56063U851
-... 56166Y438
 ... 561709692
 ... 561717661
 ... 57056B ZW1
-... 575719109
 ... 592905756
-... 61744J499
-... 640917209
 ... 640917407
-... 64122M506
 ... 643642200
-... 647108414
 ... 648018828
-... 650914203
-... 66537Y165
 ... 67065R408
 ... 67065R812
-... 670678762
 ... 670690767
 ... 670700608
-... 670725738
-... 670729599
 ... 670729730
-... 680029667
-... 68583W507
 ... 704329101
-... 70472Q302
 ... 70472Q880
-... 72200Q232
-... 72201F383
-... 72201F458
-... 72201M800
 ... 72201T664
 ... 72201U430
-... 741481105
-... 741486104
-... 74149P390
 ... 74149P648
 ... 74149P689
-... 74149P820
 ... 742935521
 ... 742935547
-... 74316P207
 ... 743185373
 ... 743185464
 ... 74318Q864
-... 74683L508
 ... 749255121
-... 74972H200
 ... 74972H283
-... 74972H390
 ... 74972H598
-... 74972K666
 ... 76628T496
 ... 77956H302
-... 783554470
 ... 783554728
 ... 784924458
 ... 803431105
 ... 803431410
-... 829334101
 ... 82980D400
 ... 884116872
 ... 890085327
-... 890085871
-... 89354D874
-... 904504560
 ... 904504586
 ... 912810EQ7
-... 912828C24
 ... 912828EG1
 ... 912828HA1
-... 912828KD1
-... 912828UA6
 ... 920461209
 ... 92646A252
-... 92913K645
 ... 92913K884
 ... 92913L775
-... 92913R822
 ... 92914A661
 ... 93208V106
-... 936793306
-... 936793504
-... 94975P686
 ... 94984B108
 ... 94984B538
 ... 949915177
 ... 949915557
 ... 957904584
-... 969251719
-... 969251834
 ... 984281204
+... FDIC99375
+... FDIC99425
 ... Y0488F100
-... Y27257149
 ... Y44425117
 ...
 ... '''

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

Summary of changes:
 stdnum/cusip.py          |   5 +-
 tests/test_cusip.doctest | 118 +++--------------------------------------------
 2 files changed, 9 insertions(+), 114 deletions(-)


hooks/post-receive
-- 
python-stdnum