File tree Expand file tree Collapse file tree 2 files changed +9
-114
lines changed Expand file tree Collapse file tree 2 files changed +9
-114
lines changed Original file line number Diff line number Diff line change 1
1
# cusip.py - functions for handling CUSIP numbers
2
2
#
3
- # Copyright (C) 2015-2017 Arthur de Jong
3
+ # Copyright (C) 2015-2022 Arthur de Jong
4
4
#
5
5
# This library is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU Lesser General Public
@@ -49,8 +49,7 @@ def compact(number):
49
49
return clean (number , ' ' ).strip ().upper ()
50
50
51
51
52
- # O and I are not valid but are accounted for in the check digit calculation
53
- _alphabet = '0123456789ABCDEFGH JKLMN PQRSTUVWXYZ*@#'
52
+ _alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#'
54
53
55
54
56
55
def calc_check_digit (number ):
Original file line number Diff line number Diff line change 1
1
test_cusip.doctest - more detailed doctests for the stdnum.cusip module
2
2
3
- Copyright (C) 2015 Arthur de Jong
3
+ Copyright (C) 2015-2022 Arthur de Jong
4
4
5
5
This library is free software; you can redistribute it and/or
6
6
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.
25
25
>>> from stdnum.exceptions import *
26
26
27
27
28
- Number should not use O (capital o) or I (capital 1) to avoid confusion with
28
+ Previously it was thought that O (capital o) or I (capital 1) were not allowed but
29
+ apparently
29
30
0 and 1:
30
31
31
- >>> cusip.validate('0O141T575')
32
- Traceback (most recent call last):
33
-
10000
span> ...
34
- InvalidFormat: ...
35
- >>> cusip.validate('257I32103')
36
- Traceback (most recent call last):
37
- ...
38
- InvalidFormat: ...
32
+ >>> cusip.validate('FDIC90903')
33
+ 'FDIC90903'
39
34
40
35
41
36
These have been found online and should all be valid numbers.
42
37
43
38
>>> numbers = '''
44
39
...
45
- ... 00078H125
46
- ... 00080Y348
47
- ... 00141H409
48
- ... 00141M572
49
- ... 00141T577
50
40
... 00141V267
51
- ... 00142F832
52
41
... 00142K500
53
- ... 00170J862
54
- ... 00170K109
55
42
... 00170M873
56
43
... 00758M261
57
44
... 024524746
58
- ... 024932808
59
45
... 024934408
60
46
... 025081704
61
- ... 025081860
62
- ... 02631C817
63
47
... 068278704
64
48
... 068278878
65
- ... 06828M405
66
49
... 101156602
67
- ... 119804102
68
- ... 12628J600
69
50
... 140543828
70
51
... 192476109
71
- ... 19765J830
72
- ... 19765N401
73
- ... 19765Y852
74
52
... 207267105
75
53
... 23336W809
76
54
... 23337G134
77
- ... 23337R502
78
- ... 23338F713
79
- ... 245908660
80
- ... 245917505
81
55
... 24610B859
82
56
... 25155T528
83
57
... 25156A668
84
58
... 25157M778
85
- ... 25159K309
86
- ... 25159L745
87
59
... 25264S403
88
60
... 254939424
89
- ... 257132100
90
- ... 258618701
91
- ... 261967103
92
61
... 261967822
93
62
... 261986566
94
63
... 265458513
95
64
... 265458570
96
65
... 269858817
97
- ... 277902565
98
- ... 277905436
99
66
... 29372R208
100
67
... 313923302
101
- ... 314172743
102
- ... 315792598
103
- ... 315805325
104
- ... 315807651
105
68
... 315911875
106
69
... 315920579
107
- ... 316069103
108
- ... 31607A208
109
- ... 316146257
110
- ... 316175850
111
- ... 31638R204
112
- ... 316390277
113
- ... 316390335
114
70
... 316390640
115
- ... 316390681
116
71
... 320600109
117
- ... 320604606
118
72
... 320917107
119
- ... 353496854
120
- ... 353535107
121
73
... 354128704
122
74
... 354723769
123
- ... 36158T506
124
75
... 409902624
125
76
... 416649507
126
- ... 416649606
127
77
... 425888104
128
- ... 42588P825
129
- ... 42588P882
130
- ... 44929K630
131
78
... 461418691
132
79
... 465898682
133
80
... 469785109
134
81
... 471023531
135
82
... 47803M663
136
- ... 4812A4427
137
83
... 4812C0548
138
- ... 52106N335
139
84
... 52106N442
140
- ... 52106N632
141
- ... 52106N657
142
85
... 543912604
143
- ... 543913305
144
- ... 552984601
145
- ... 552986309
146
- ... 552986853
147
- ... 557492428
148
86
... 56063J849
149
- ... 56063U851
150
- ... 56166Y438
151
87
... 561709692
152
88
... 561717661
153
89
... 57056B ZW1
154
- ... 575719109
155
90
... 592905756
156
- ... 61744J499
157
- ... 640917209
158
91
... 640917407
159
- ... 64122M506
160
92
... 643642200
161
- ... 647108414
162
93
... 648018828
163
- ... 650914203
164
- ... 66537Y165
165
94
... 67065R408
166
95
... 67065R812
167
- ... 670678762
168
96
... 670690767
169
97
... 670700608
170
- ... 670725738
171
- ... 670729599
172
98
... 670729730
173
- ... 680029667
174
- ... 68583W507
175
99
... 704329101
176
- ... 70472Q302
177
100
... 70472Q880
178
- ... 72200Q232
179
- ... 72201F383
180
- ... 72201F458
181
- ... 72201M800
182
101
... 72201T664
183
102
... 72201U430
184
- ... 741481105
185
- ... 741486104
186
- ... 74149P390
187
103
... 74149P648
188
104
... 74149P689
189
- ... 74149P820
190
105
... 742935521
191
106
... 742935547
192
- ... 74316P207
193
107
... 743185373
194
108
... 743185464
195
109
... 74318Q864
196
- ... 74683L508
197
110
... 749255121
198
- ... 74972H200
199
111
... 74972H283
200
- ... 74972H390
201
112
... 74972H598
202
- ... 74972K666
203
113
... 76628T496
204
114
... 77956H302
205
- ... 783554470
206
115
... 783554728
207
116
... 784924458
208
117
... 803431105
209
118
... 803431410
210
- ... 829334101
211
119
... 82980D400
212
120
... 884116872
213
121
... 890085327
214
- ... 890085871
215
- ... 89354D874
216
- ... 904504560
217
122
... 904504586
218
123
... 912810EQ7
219
- ... 912828C24
220
124
... 912828EG1
221
125
... 912828HA1
222
- ... 912828KD1
223
- ... 912828UA6
224
126
... 920461209
225
127
... 92646A252
226
- ... 92913K645
227
128
... 92913K884
228
129
... 92913L775
229
- ... 92913R822
230
130
... 92914A661
231
131
... 93208V106
232
- ... 936793306
233
- ... 936793504
234
- ... 94975P686
235
132
... 94984B108
236
133
... 94984B538
237
134
... 949915177
238
135
... 949915557
239
136
... 957904584
240
- ... 969251719
241
- ... 969251834
242
137
... 984281204
138
+ ... FDIC99375
139
+ ... FDIC99425
243
140
... Y0488F100
244
- ... Y27257149
245
141
... Y44425117
246
142
...
247
143
... '''
You can’t perform that action at this time.
0 commit comments