idstring 2.0.3__tar.gz → 2.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- idstring-2.1.4/PKG-INFO +110 -0
- {idstring-2.0.3 → idstring-2.1.4}/README.md +26 -7
- idstring-2.1.4/idstring/__init__.py +3 -0
- {idstring-2.0.3 → idstring-2.1.4/idstring}/idstring.py +31 -21
- idstring-2.1.4/idstring.egg-info/PKG-INFO +110 -0
- {idstring-2.0.3 → idstring-2.1.4}/idstring.egg-info/SOURCES.txt +5 -4
- idstring-2.1.4/pyproject.toml +29 -0
- idstring-2.1.4/setup.cfg +4 -0
- idstring-2.1.4/setup.py +4 -0
- idstring-2.1.4/test/test_idstring.py +259 -0
- idstring-2.0.3/MANIFEST.in +0 -2
- idstring-2.0.3/PKG-INFO +0 -32
- idstring-2.0.3/idstring.egg-info/PKG-INFO +0 -32
- idstring-2.0.3/setup.cfg +0 -10
- idstring-2.0.3/setup.py +0 -54
- {idstring-2.0.3 → idstring-2.1.4}/idstring.egg-info/dependency_links.txt +0 -0
- {idstring-2.0.3 → idstring-2.1.4}/idstring.egg-info/top_level.txt +0 -0
idstring-2.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: idstring
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: A Python package to create unique, checksummed serial-number strings.
|
|
5
|
+
Author: Vernon Cole
|
|
6
|
+
Author-email: vernondcole@gmail.com
|
|
7
|
+
Project-URL: repository, https://github.com/vernondcole/idstring
|
|
8
|
+
Project-URL: documentation, https://github.com/vernondcole/idstring/wiki
|
|
9
|
+
Keywords: serial number,string,checksum,Luhn,increment
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
idstring
|
|
21
|
+
========
|
|
22
|
+
|
|
23
|
+
Python module to create alpha-numeric serial number strings with a check digit, with smart incrementing.
|
|
24
|
+
|
|
25
|
+
an IDstring is a string-like object which can be incremented, to produce
|
|
26
|
+
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
27
|
+
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
28
|
+
(by defaut) an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
29
|
+
|
|
30
|
+
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
31
|
+
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
32
|
+
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
33
|
+
|
|
34
|
+
For more explanation, please refer to [the wiki on github](https://github.com/vernondcole/idstring/wiki)
|
|
35
|
+
|
|
36
|
+
class IDstring generates (and checks) alphanumeric serial number strings with a checksum
|
|
37
|
+
|
|
38
|
+
### changes:
|
|
39
|
+
|
|
40
|
+
* 2018 Update: Still works fine in Python 3.6. No issues have been filed, no bugs reported.
|
|
41
|
+
|
|
42
|
+
* 2022 Update: works with Python 3.10. Python 2.7 dropped. Version 2.0.1
|
|
43
|
+
|
|
44
|
+
* Version 2.0:
|
|
45
|
+
* Added ability to pass hash=None to turn off checksums.
|
|
46
|
+
* Support for lower-case letters in alphabets.
|
|
47
|
+
* Assigning alternate alphabets (etc.) during instance creation.
|
|
48
|
+
* Choice of automatic case shift upper, lower, or None.
|
|
49
|
+
* Some small breaking changes. Especially . . .
|
|
50
|
+
* The use of IdString(seed='sss') syntax is required in usual cases when manually creating a new instance.
|
|
51
|
+
* The wonky 5-bit binary conversion functions, which only worked with the default alphabet, have been removed.
|
|
52
|
+
* Version 2.1:
|
|
53
|
+
* adds a .context dictionary to the IDstring object which a seedstore method can use to store its operating context.
|
|
54
|
+
|
|
55
|
+
### operation:
|
|
56
|
+
IDstring extends the built-in str class, using an __ADD__ method which accepts the integer ONE.
|
|
57
|
+
Adding 1 to an instance of the class will generate a new instance with an incremented value (and a new checksum).
|
|
58
|
+
|
|
59
|
+
So, in short, you can generate serial numbers like this:
|
|
60
|
+
|
|
61
|
+
serial = idstring.IDstring(seed='1Y3R9C')
|
|
62
|
+
while serial.startswith('1'): # notice that it is like a string, so .startswith works.
|
|
63
|
+
serial += 1 # Increments the string & generates a new checksum.
|
|
64
|
+
print(serial)
|
|
65
|
+
|
|
66
|
+
Gives a result series which starts with "1Y3R9CB" and loops 925,386 times, ending with:
|
|
67
|
+
```
|
|
68
|
+
1YYYYVA
|
|
69
|
+
1YYYYW8
|
|
70
|
+
1YYYYX6
|
|
71
|
+
1YYYYY4
|
|
72
|
+
200000X
|
|
73
|
+
```
|
|
74
|
+
Incrementation flows smoothly through the alphabet -- "9" increments to "A". Incrementing "Y" gives "0" and
|
|
75
|
+
causes a carry to increment the next digit. If you run out of digits, a "1" is prepended to the string.
|
|
76
|
+
(By default. Alternate alphabets increment in their implied order.
|
|
77
|
+
The actual code for a new leading digit is: "carry_digit = '1' if self.alphabet[0] == '0' else self.alphabet[0]")
|
|
78
|
+
|
|
79
|
+
The "Luhn mod N" algorithm is used (unless disabled) to add another digit (from the same alphabet) as a check digit.
|
|
80
|
+
|
|
81
|
+
The routine will automatically skip over patterns which contain substrings matching a list of "Dirty Words."
|
|
82
|
+
The above example should have been expected to produce 95396 results, but skipped 10 objectionable values.
|
|
83
|
+
|
|
84
|
+
You can override the supplied alphabet and objectionable word lists. Alternate alphabets overflow correctly.
|
|
85
|
+
|
|
86
|
+
You may supply an optional call-back function to assist in maintaining the persistence of the serial number
|
|
87
|
+
sequence of multiple program runs.
|
|
88
|
+
|
|
89
|
+
The Luhn-N check digit will detect any single character substitution, any inversion of adjacent characters
|
|
90
|
+
(except the first and last character in the alphabet: i.e. 0<->Y for the supplied default) and most other errors.
|
|
91
|
+
|
|
92
|
+
The default alphabet consists of [0-9] and [A-Y] dropping "I", "O", and "Q".
|
|
93
|
+
|
|
94
|
+
Provision is made for a fixed subfield (of user defined length) between the check digit and the incrementing
|
|
95
|
+
field, so that multiple sites can produce non-overlapping series of numbers. This subfield and the check digit
|
|
96
|
+
are included in the "dirty word" checking.
|
|
97
|
+
|
|
98
|
+
### still don't understand?
|
|
99
|
+
Read the source, Luke.
|
|
100
|
+
https://pypi.org/project/idstring/#files
|
|
101
|
+
|
|
102
|
+
Read (and then test run) the program sample_seedstore.py to see how it works.
|
|
103
|
+
|
|
104
|
+
Run "python sample_seedstore.py" from multiple terminals to observe how it uses
|
|
105
|
+
a one-row SQL database to maintain the seed value and gives unique values.
|
|
106
|
+
|
|
107
|
+
### installation:
|
|
108
|
+
Installation uses the usual Python methods:
|
|
109
|
+
|
|
110
|
+
pip install idstring
|
|
@@ -3,10 +3,21 @@ idstring
|
|
|
3
3
|
|
|
4
4
|
Python module to create alpha-numeric serial number strings with a check digit, with smart incrementing.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
an IDstring is a string-like object which can be incremented, to produce
|
|
7
|
+
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
8
|
+
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
9
|
+
(by defaut) an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
10
|
+
|
|
11
|
+
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
12
|
+
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
13
|
+
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
14
|
+
|
|
15
|
+
For more explanation, please refer to [the wiki on github](https://github.com/vernondcole/idstring/wiki)
|
|
7
16
|
|
|
8
17
|
class IDstring generates (and checks) alphanumeric serial number strings with a checksum
|
|
9
18
|
|
|
19
|
+
### changes:
|
|
20
|
+
|
|
10
21
|
* 2018 Update: Still works fine in Python 3.6. No issues have been filed, no bugs reported.
|
|
11
22
|
|
|
12
23
|
* 2022 Update: works with Python 3.10. Python 2.7 dropped. Version 2.0.1
|
|
@@ -19,8 +30,11 @@ class IDstring generates (and checks) alphanumeric serial number strings with a
|
|
|
19
30
|
* Some small breaking changes. Especially . . .
|
|
20
31
|
* The use of IdString(seed='sss') syntax is required in usual cases when manually creating a new instance.
|
|
21
32
|
* The wonky 5-bit binary conversion functions, which only worked with the default alphabet, have been removed.
|
|
33
|
+
* Version 2.1:
|
|
34
|
+
* adds a .context dictionary to the IDstring object which a seedstore method can use to store its operating context.
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
### operation:
|
|
37
|
+
IDstring extends the built-in str class, using an __ADD__ method which accepts the integer ONE.
|
|
24
38
|
Adding 1 to an instance of the class will generate a new instance with an incremented value (and a new checksum).
|
|
25
39
|
|
|
26
40
|
So, in short, you can generate serial numbers like this:
|
|
@@ -62,11 +76,16 @@ Provision is made for a fixed subfield (of user defined length) between the chec
|
|
|
62
76
|
field, so that multiple sites can produce non-overlapping series of numbers. This subfield and the check digit
|
|
63
77
|
are included in the "dirty word" checking.
|
|
64
78
|
|
|
79
|
+
### still don't understand?
|
|
80
|
+
Read the source, Luke.
|
|
81
|
+
https://pypi.org/project/idstring/#files
|
|
82
|
+
|
|
83
|
+
Read (and then test run) the program sample_seedstore.py to see how it works.
|
|
84
|
+
|
|
85
|
+
Run "python sample_seedstore.py" from multiple terminals to observe how it uses
|
|
86
|
+
a one-row SQL database to maintain the seed value and gives unique values.
|
|
87
|
+
|
|
88
|
+
### installation:
|
|
65
89
|
Installation uses the usual Python methods:
|
|
66
90
|
|
|
67
|
-
cd your-unzipped-directory
|
|
68
|
-
python setup.py install
|
|
69
|
-
|
|
70
|
-
or
|
|
71
|
-
|
|
72
91
|
pip install idstring
|
|
@@ -28,7 +28,7 @@ The string is initialized using a five-argument call like; idstring.IDstring(IDs
|
|
|
28
28
|
from collections.abc import Callable
|
|
29
29
|
|
|
30
30
|
__author__ = "Vernon Cole <vernondcole@gmail.com>"
|
|
31
|
-
__version__ = "2.
|
|
31
|
+
__version__ = "2.1.4"
|
|
32
32
|
|
|
33
33
|
# -- a short calling sample -- real code would use a better storage method ---------
|
|
34
34
|
#- import pickle, idstring
|
|
@@ -61,10 +61,6 @@ __version__ = "2.0.3"
|
|
|
61
61
|
#-
|
|
62
62
|
#-----------------------------------------------------------------------
|
|
63
63
|
|
|
64
|
-
#Define exceptions
|
|
65
|
-
import idstring
|
|
66
|
-
|
|
67
|
-
|
|
68
64
|
class IdStringError(ValueError):
|
|
69
65
|
"""Base class for all errors in the IdString package"""
|
|
70
66
|
pass
|
|
@@ -84,7 +80,7 @@ DEFAULT_ALPHABET = "0123456789ABCDEFGHJKLMNPRSTUVWXY"
|
|
|
84
80
|
|
|
85
81
|
# create a list of George Carlan's "the seven words you can't say on T.V."
|
|
86
82
|
# plus a few extras, but ignoring those with an "I" in them, since the default ALPHABET has no "I"
|
|
87
|
-
DEFAULT_DIRTY_WORDS = [c[::-1] for c in ['KCUF', 'TNUC', 'TRAF', 'DRUT', 'TAWT', 'SLLAB']]
|
|
83
|
+
DEFAULT_DIRTY_WORDS = [c[::-1] for c in ['KCUF', 'TNUC', 'TRAF', 'DRUT', 'TAWT', 'SLLAB', 'SSA']]
|
|
88
84
|
DIRTY_I_WORDS = [c[::-1] for c in ['TIHS', 'TIT', 'SSIP']] # if your alternate alphabet contains an "I"
|
|
89
85
|
# alter your list like--> IDstring.DIRTY_WORDS = idstring.DEFAULT_DIRTY_WORDS + idstring.DIRTY_I_WORDS
|
|
90
86
|
# the words are stored backwards in the source, because 'kcuf' is not objectionable.
|
|
@@ -128,12 +124,13 @@ class IDstring(str):
|
|
|
128
124
|
|
|
129
125
|
@staticmethod
|
|
130
126
|
def __new__(cls, idstr=None, seed=None, host='', seedstore=None, hash='', alphabet=None,
|
|
131
|
-
case_shift=DEFAULT_CASE_SHIFT, no_check=False):
|
|
127
|
+
case_shift=DEFAULT_CASE_SHIFT, no_check=False, context={}):
|
|
132
128
|
"""
|
|
133
129
|
:S - an existing legal idString, or None
|
|
134
130
|
:seed - the seed string for a new factory [ignored unless S is None]
|
|
135
131
|
:host - the host portion for a new idString factory, len(host) will set host length for factory
|
|
136
132
|
:seedstore - a seed preservation function for the new factory
|
|
133
|
+
:context - a dictionary of things reserved for seedstore to use, internal to seedstore
|
|
137
134
|
:hash - an additional string to alter the calculation of the check digit for diverse projects
|
|
138
135
|
pass hash=None to turn off checksum testing and creation. Makes this module dumb.
|
|
139
136
|
:case_shift - function to apply to input strings. one of str.upper str.lower or None
|
|
@@ -150,14 +147,16 @@ class IDstring(str):
|
|
|
150
147
|
alphabet = alphabet or IDstring.ALPHABET
|
|
151
148
|
value = None
|
|
152
149
|
if isinstance(idstr, cls):
|
|
153
|
-
value = str(idstr)
|
|
154
150
|
if host != idstr.host:
|
|
155
151
|
raise InvalidIdError(f'Cannot use host "{host}" with id "{value}"')
|
|
156
|
-
seed
|
|
152
|
+
if seed is None: # making a clone
|
|
153
|
+
value = str(idstr)
|
|
154
|
+
seed = idstr._seed
|
|
157
155
|
hash = idstr.hash
|
|
158
156
|
alphabet = idstr.alphabet
|
|
159
157
|
seedstore = idstr.seedstore
|
|
160
158
|
case_shift = idstr.case_shift
|
|
159
|
+
context = idstr.context
|
|
161
160
|
elif isinstance(idstr, str):
|
|
162
161
|
us = case_shift(idstr) # if passing a string as on IDstring, it must already have a checksum
|
|
163
162
|
if no_check:
|
|
@@ -175,7 +174,7 @@ class IDstring(str):
|
|
|
175
174
|
raise InvalidIdError(f'No valid ID in id="{idstr}" or seed="{seed}"')
|
|
176
175
|
value = case_shift(value)
|
|
177
176
|
new = super().__new__(cls, value) #create the new instance
|
|
178
|
-
new.
|
|
177
|
+
new._seed = seed # fill in the new instances attributes (as if we were __init__)
|
|
179
178
|
new.host = host
|
|
180
179
|
new.hash = hash
|
|
181
180
|
new.alphabet = alphabet
|
|
@@ -183,24 +182,32 @@ class IDstring(str):
|
|
|
183
182
|
if not isinstance(seedstore, Callable):
|
|
184
183
|
raise IdStringError ('seedstore "%s" is not Callable' % repr(seedstore))
|
|
185
184
|
new.seedstore = seedstore
|
|
185
|
+
new.context = context
|
|
186
186
|
new.case_shift = case_shift
|
|
187
187
|
return new
|
|
188
188
|
|
|
189
189
|
|
|
190
|
+
@property
|
|
191
|
+
def seed(self):
|
|
192
|
+
return self.get_seed()
|
|
193
|
+
|
|
194
|
+
|
|
190
195
|
def get_seed(self):
|
|
191
196
|
"""extracts the incrementable part (without the host and checksum digits) of the IDstring"""
|
|
192
197
|
try:
|
|
193
|
-
|
|
198
|
+
stored_seed = self._seed
|
|
194
199
|
except AttributeError:
|
|
195
|
-
|
|
196
|
-
if
|
|
200
|
+
stored_seed = None
|
|
201
|
+
if stored_seed is None:
|
|
197
202
|
inc = 0 if self.hash is None else 1
|
|
198
203
|
try:
|
|
199
204
|
n = len(self.host) + inc
|
|
200
205
|
except TypeError:
|
|
201
206
|
n = inc
|
|
202
207
|
ret = str(self)[:-n] if n > 0 else str(self)
|
|
203
|
-
|
|
208
|
+
self._seed = ret # cache for next time
|
|
209
|
+
return ret
|
|
210
|
+
return stored_seed
|
|
204
211
|
|
|
205
212
|
|
|
206
213
|
def _next_value(self):
|
|
@@ -223,7 +230,7 @@ class IDstring(str):
|
|
|
223
230
|
cat = carry_digit + cat # add a new place
|
|
224
231
|
keep_looping = False
|
|
225
232
|
seed = seed[:n] + cat
|
|
226
|
-
self.
|
|
233
|
+
self._seed = seed
|
|
227
234
|
return _checksum(seed + self.host, self.hash, self.alphabet)
|
|
228
235
|
|
|
229
236
|
|
|
@@ -247,7 +254,7 @@ class IDstring(str):
|
|
|
247
254
|
next_value = _checksum(next_root, self.hash, self.alphabet)
|
|
248
255
|
else:
|
|
249
256
|
next_value = self._run_factory() # will this ever happen?
|
|
250
|
-
del self.
|
|
257
|
+
del self._seed # invalidate cached seed
|
|
251
258
|
return next_value
|
|
252
259
|
|
|
253
260
|
|
|
@@ -255,14 +262,17 @@ class IDstring(str):
|
|
|
255
262
|
"""supports 'IDstring + 1' to generate the next serial number. (all other addends just do str concat)
|
|
256
263
|
|
|
257
264
|
if idstring.host was defined, skip that many characters before incrementing
|
|
258
|
-
|
|
265
|
+
if seedstore() returns a value (other than None) that will become the new incremented value
|
|
259
266
|
"""
|
|
260
267
|
if other == 1:
|
|
261
268
|
next_thing = self._run_factory()
|
|
269
|
+
# Python strings are immutable, so we must create a new instance
|
|
262
270
|
ret = IDstring(next_thing, host=self.host, seedstore=self.seedstore, hash=self.hash,
|
|
263
|
-
case_shift=self.case_shift, alphabet=self.alphabet, no_check=True)
|
|
271
|
+
case_shift=self.case_shift, alphabet=self.alphabet, no_check=True, context=self.context)
|
|
264
272
|
if ret.seedstore: # call the seedstore function supplied by the program, with "self" as an argument
|
|
265
|
-
ret.seedstore(ret)
|
|
273
|
+
correction = ret.seedstore(ret)
|
|
274
|
+
if correction: # user can return a new, improved ID value
|
|
275
|
+
return correction
|
|
266
276
|
return ret
|
|
267
277
|
else:
|
|
268
278
|
return str(self) + other
|
|
@@ -346,8 +356,8 @@ def _sumcheck(s, hash='', alphabet=None, case_shift=None):
|
|
|
346
356
|
alphabet = IDstring.ALPHABET
|
|
347
357
|
if case_shift is None:
|
|
348
358
|
case_shift = DEFAULT_CASE_SHIFT
|
|
349
|
-
if hash is None: # checksums are not in use.
|
|
350
|
-
for c in case_shift(s):
|
|
359
|
+
if hash is None: # if checksums are not in use. . .
|
|
360
|
+
for c in case_shift(s): # just check for valid characters
|
|
351
361
|
if c not in alphabet:
|
|
352
362
|
return False
|
|
353
363
|
return True
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: idstring
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: A Python package to create unique, checksummed serial-number strings.
|
|
5
|
+
Author: Vernon Cole
|
|
6
|
+
Author-email: vernondcole@gmail.com
|
|
7
|
+
Project-URL: repository, https://github.com/vernondcole/idstring
|
|
8
|
+
Project-URL: documentation, https://github.com/vernondcole/idstring/wiki
|
|
9
|
+
Keywords: serial number,string,checksum,Luhn,increment
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
idstring
|
|
21
|
+
========
|
|
22
|
+
|
|
23
|
+
Python module to create alpha-numeric serial number strings with a check digit, with smart incrementing.
|
|
24
|
+
|
|
25
|
+
an IDstring is a string-like object which can be incremented, to produce
|
|
26
|
+
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
27
|
+
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
28
|
+
(by defaut) an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
29
|
+
|
|
30
|
+
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
31
|
+
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
32
|
+
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
33
|
+
|
|
34
|
+
For more explanation, please refer to [the wiki on github](https://github.com/vernondcole/idstring/wiki)
|
|
35
|
+
|
|
36
|
+
class IDstring generates (and checks) alphanumeric serial number strings with a checksum
|
|
37
|
+
|
|
38
|
+
### changes:
|
|
39
|
+
|
|
40
|
+
* 2018 Update: Still works fine in Python 3.6. No issues have been filed, no bugs reported.
|
|
41
|
+
|
|
42
|
+
* 2022 Update: works with Python 3.10. Python 2.7 dropped. Version 2.0.1
|
|
43
|
+
|
|
44
|
+
* Version 2.0:
|
|
45
|
+
* Added ability to pass hash=None to turn off checksums.
|
|
46
|
+
* Support for lower-case letters in alphabets.
|
|
47
|
+
* Assigning alternate alphabets (etc.) during instance creation.
|
|
48
|
+
* Choice of automatic case shift upper, lower, or None.
|
|
49
|
+
* Some small breaking changes. Especially . . .
|
|
50
|
+
* The use of IdString(seed='sss') syntax is required in usual cases when manually creating a new instance.
|
|
51
|
+
* The wonky 5-bit binary conversion functions, which only worked with the default alphabet, have been removed.
|
|
52
|
+
* Version 2.1:
|
|
53
|
+
* adds a .context dictionary to the IDstring object which a seedstore method can use to store its operating context.
|
|
54
|
+
|
|
55
|
+
### operation:
|
|
56
|
+
IDstring extends the built-in str class, using an __ADD__ method which accepts the integer ONE.
|
|
57
|
+
Adding 1 to an instance of the class will generate a new instance with an incremented value (and a new checksum).
|
|
58
|
+
|
|
59
|
+
So, in short, you can generate serial numbers like this:
|
|
60
|
+
|
|
61
|
+
serial = idstring.IDstring(seed='1Y3R9C')
|
|
62
|
+
while serial.startswith('1'): # notice that it is like a string, so .startswith works.
|
|
63
|
+
serial += 1 # Increments the string & generates a new checksum.
|
|
64
|
+
print(serial)
|
|
65
|
+
|
|
66
|
+
Gives a result series which starts with "1Y3R9CB" and loops 925,386 times, ending with:
|
|
67
|
+
```
|
|
68
|
+
1YYYYVA
|
|
69
|
+
1YYYYW8
|
|
70
|
+
1YYYYX6
|
|
71
|
+
1YYYYY4
|
|
72
|
+
200000X
|
|
73
|
+
```
|
|
74
|
+
Incrementation flows smoothly through the alphabet -- "9" increments to "A". Incrementing "Y" gives "0" and
|
|
75
|
+
causes a carry to increment the next digit. If you run out of digits, a "1" is prepended to the string.
|
|
76
|
+
(By default. Alternate alphabets increment in their implied order.
|
|
77
|
+
The actual code for a new leading digit is: "carry_digit = '1' if self.alphabet[0] == '0' else self.alphabet[0]")
|
|
78
|
+
|
|
79
|
+
The "Luhn mod N" algorithm is used (unless disabled) to add another digit (from the same alphabet) as a check digit.
|
|
80
|
+
|
|
81
|
+
The routine will automatically skip over patterns which contain substrings matching a list of "Dirty Words."
|
|
82
|
+
The above example should have been expected to produce 95396 results, but skipped 10 objectionable values.
|
|
83
|
+
|
|
84
|
+
You can override the supplied alphabet and objectionable word lists. Alternate alphabets overflow correctly.
|
|
85
|
+
|
|
86
|
+
You may supply an optional call-back function to assist in maintaining the persistence of the serial number
|
|
87
|
+
sequence of multiple program runs.
|
|
88
|
+
|
|
89
|
+
The Luhn-N check digit will detect any single character substitution, any inversion of adjacent characters
|
|
90
|
+
(except the first and last character in the alphabet: i.e. 0<->Y for the supplied default) and most other errors.
|
|
91
|
+
|
|
92
|
+
The default alphabet consists of [0-9] and [A-Y] dropping "I", "O", and "Q".
|
|
93
|
+
|
|
94
|
+
Provision is made for a fixed subfield (of user defined length) between the check digit and the incrementing
|
|
95
|
+
field, so that multiple sites can produce non-overlapping series of numbers. This subfield and the check digit
|
|
96
|
+
are included in the "dirty word" checking.
|
|
97
|
+
|
|
98
|
+
### still don't understand?
|
|
99
|
+
Read the source, Luke.
|
|
100
|
+
https://pypi.org/project/idstring/#files
|
|
101
|
+
|
|
102
|
+
Read (and then test run) the program sample_seedstore.py to see how it works.
|
|
103
|
+
|
|
104
|
+
Run "python sample_seedstore.py" from multiple terminals to observe how it uses
|
|
105
|
+
a one-row SQL database to maintain the seed value and gives unique values.
|
|
106
|
+
|
|
107
|
+
### installation:
|
|
108
|
+
Installation uses the usual Python methods:
|
|
109
|
+
|
|
110
|
+
pip install idstring
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
MANIFEST.in
|
|
2
1
|
README.md
|
|
3
|
-
|
|
4
|
-
setup.cfg
|
|
2
|
+
pyproject.toml
|
|
5
3
|
setup.py
|
|
4
|
+
idstring/__init__.py
|
|
5
|
+
idstring/idstring.py
|
|
6
6
|
idstring.egg-info/PKG-INFO
|
|
7
7
|
idstring.egg-info/SOURCES.txt
|
|
8
8
|
idstring.egg-info/dependency_links.txt
|
|
9
|
-
idstring.egg-info/top_level.txt
|
|
9
|
+
idstring.egg-info/top_level.txt
|
|
10
|
+
test/test_idstring.py
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = 'idstring'
|
|
3
|
+
description = 'A Python package to create unique, checksummed serial-number strings.'
|
|
4
|
+
authors = [{name = 'Vernon Cole'},{email = "vernondcole@gmail.com"}]
|
|
5
|
+
dependencies = []
|
|
6
|
+
dynamic = ['version'] # set from __version__ in idstring.py
|
|
7
|
+
keywords = ["serial number", "string", "checksum", "Luhn", "increment"]
|
|
8
|
+
classifiers = [
|
|
9
|
+
'Development Status :: 5 - Production/Stable',
|
|
10
|
+
'Intended Audience :: Developers',
|
|
11
|
+
'License :: OSI Approved :: GNU General Public License (GPL)',
|
|
12
|
+
'Programming Language :: Python',
|
|
13
|
+
'Natural Language :: English',
|
|
14
|
+
'Operating System :: OS Independent',
|
|
15
|
+
'Topic :: Software Development',
|
|
16
|
+
'Topic :: Software Development :: Libraries :: Python Modules'
|
|
17
|
+
]
|
|
18
|
+
readme = "README.md"
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
repository = "https://github.com/vernondcole/idstring"
|
|
22
|
+
documentation = "https://github.com/vernondcole/idstring/wiki"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["setuptools", "wheel", "build"]
|
|
26
|
+
build-backend = "setuptools.build_meta"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.dynamic]
|
|
29
|
+
version = {attr = "idstring.__version__"}
|
idstring-2.1.4/setup.cfg
ADDED
idstring-2.1.4/setup.py
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Test code for the IDstring package
|
|
4
|
+
"""
|
|
5
|
+
__author__ = 'vernon'
|
|
6
|
+
|
|
7
|
+
import sys, os
|
|
8
|
+
mommy = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
|
|
9
|
+
sys.path.insert(1, mommy) # use the local copy, not some system version
|
|
10
|
+
|
|
11
|
+
import idstring
|
|
12
|
+
from idstring.idstring import IDstring, InvalidIdError
|
|
13
|
+
import unittest
|
|
14
|
+
import random
|
|
15
|
+
from contextlib import contextmanager
|
|
16
|
+
|
|
17
|
+
dummy_seed = None # Glabal variable used for ephemeral seed storage
|
|
18
|
+
|
|
19
|
+
def assertion(seen, expected, seed=None):
|
|
20
|
+
assert str(seen) == expected, 'Value is "%s". expected "%s"' % (seen, expected)
|
|
21
|
+
if seed:
|
|
22
|
+
assert dummy_seed == seed, 'seed returned was "%s" expected "%s"' % (seen, dummy_seed)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# the seedstore function will be called back with an IDstring object as its only argument
|
|
26
|
+
def dummy(idstr): # nonfunctional seedstore function
|
|
27
|
+
global dummy_seed
|
|
28
|
+
d = idstr.get_seed() # the seed we need to preserve
|
|
29
|
+
dummy_seed = d # just store it in a global variable for test purposes
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Test1(unittest.TestCase):
|
|
33
|
+
def test1(self):
|
|
34
|
+
#test building a factory
|
|
35
|
+
fact = IDstring(seed='90a', host='1234', seedstore=dummy)
|
|
36
|
+
#value comes back unchanged
|
|
37
|
+
assertion(fact, '90A1234A', None)
|
|
38
|
+
#try the next value
|
|
39
|
+
x = fact + 1
|
|
40
|
+
assertion(x, '90B12348', '90B')
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Test2(unittest.TestCase):
|
|
44
|
+
def test2(self):
|
|
45
|
+
#test the carry
|
|
46
|
+
fact = IDstring(seed='000Y', host='ppp', seedstore=dummy)
|
|
47
|
+
x = fact + 1
|
|
48
|
+
assertion(x, '0010PPP9', '0010')
|
|
49
|
+
def test2a(self):
|
|
50
|
+
#test carry out of top digit
|
|
51
|
+
fact = IDstring(seed='YYYY')
|
|
52
|
+
x = fact + 1
|
|
53
|
+
assertion(x, '10000X')
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Test3(unittest.TestCase):
|
|
57
|
+
def test3(self):
|
|
58
|
+
# test the checksum interface
|
|
59
|
+
assert IDstring.sumcheck('TESTME2K'), 'valid checksum shown as invalid'
|
|
60
|
+
try:
|
|
61
|
+
assert IDstring('TESTME3K'), 'invalid checksum should not pass'
|
|
62
|
+
except InvalidIdError:
|
|
63
|
+
pass
|
|
64
|
+
else:
|
|
65
|
+
self.fail('Did not see OutOfRangeError')
|
|
66
|
+
|
|
67
|
+
def test3b(self):
|
|
68
|
+
assert not IDstring.sumcheck('TSETME2K'), 'invalid checksum should not pass'
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Test4(unittest.TestCase):
|
|
72
|
+
# test the dirty word eliminator
|
|
73
|
+
|
|
74
|
+
def test4(self): #test that we skip bad words on the right
|
|
75
|
+
f = IDstring(seed='dcasr')
|
|
76
|
+
assertion(f, 'DCASRV')
|
|
77
|
+
x = f + 1
|
|
78
|
+
assertion(x, 'DCASTR') #skips the bad word 'ass'
|
|
79
|
+
|
|
80
|
+
def test4b(self):
|
|
81
|
+
#test that we skip bad words on the left
|
|
82
|
+
f = IDstring(seed='fucjyyy', seedstore=dummy)
|
|
83
|
+
x = f + 1 #skip you, too, buddy
|
|
84
|
+
assertion(x, 'FUCL000U', 'FUCL000')
|
|
85
|
+
|
|
86
|
+
def test4c(self): # test the case where a checksum causes a bad word
|
|
87
|
+
f = IDstring(seed='000vfub', seedstore=dummy)
|
|
88
|
+
x = f + 1 # '000VFUC' has a checksum of 'K'
|
|
89
|
+
assertion(x, '000VFUDH', '000VFUD')
|
|
90
|
+
|
|
91
|
+
def test4d(self): # test the case where a host field causes a bad word
|
|
92
|
+
f = IDstring(seed='0ct', host='nt', seedstore=dummy)
|
|
93
|
+
x = f + 1 #
|
|
94
|
+
assertion(x,'0CVNTG', '0CV')
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class Test5(unittest.TestCase):
|
|
98
|
+
# test the checksum algorithm as a whole
|
|
99
|
+
def test5(self):
|
|
100
|
+
alphabet = IDstring.ALPHABET
|
|
101
|
+
def ranlets(size,allowed=alphabet): # a function to generate a random string of our alphabet
|
|
102
|
+
randomstring = ''.join([allowed[random.randint(0, len(allowed) - 1)] for x in range(size)])
|
|
103
|
+
return randomstring
|
|
104
|
+
|
|
105
|
+
# run the test using many different random strings
|
|
106
|
+
for N in range(1000):
|
|
107
|
+
jumble = IDstring(seed=ranlets(random.randint(2, 20))) # make a random length random string
|
|
108
|
+
for i,should_be in enumerate(jumble): # for each character in that string
|
|
109
|
+
others = list(alphabet) # replace it with every other possible character
|
|
110
|
+
others.remove(should_be)
|
|
111
|
+
for c in others: #try every possible other value for this character
|
|
112
|
+
mumble = ''.join([jumble[:i], c, jumble[i+1:]])
|
|
113
|
+
assert not IDstring.sumcheck(mumble), 'IDstring "%s" should fail checksum'
|
|
114
|
+
# now test digit flips
|
|
115
|
+
# -- swap a character with its next door neighbor
|
|
116
|
+
# (this is the most common transcription error when humans are involved)
|
|
117
|
+
# Note: this algorithm will not detect flips of the first and last characters of its alphabet
|
|
118
|
+
# (called a 0-9 flip when only decimal digits are used)
|
|
119
|
+
#
|
|
120
|
+
for i in range(len(jumble)-1):
|
|
121
|
+
j = i+1 # skip test of letters are the same -- or if letters are first and last
|
|
122
|
+
if jumble[i] != jumble[j] and {jumble[i],jumble[j]} != {alphabet[0],alphabet[-1]}:
|
|
123
|
+
s = list(jumble)
|
|
124
|
+
s[j], s[i] = s[i], s[j] # swap two characters
|
|
125
|
+
mumble = ''.join(s)
|
|
126
|
+
assert not IDstring.sumcheck(mumble), 'checksum error in "%s" when changed to "%s"'%(jumble,mumble)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class Test6(unittest.TestCase):
|
|
130
|
+
# test weird extra functions
|
|
131
|
+
def test6(self):
|
|
132
|
+
# seed in binary is deprecated
|
|
133
|
+
self.assertRaises(idstring.InvalidIdError, IDstring, [], **{'seed': 0})
|
|
134
|
+
|
|
135
|
+
f = IDstring(seed='0')
|
|
136
|
+
assertion(f, '00')
|
|
137
|
+
x = f + 1
|
|
138
|
+
assertion(x, u'1X')
|
|
139
|
+
x = f + 1 # !! do not use this terrible side effect !!!
|
|
140
|
+
self.assertNotEqual(x, '2V')
|
|
141
|
+
|
|
142
|
+
x += 1
|
|
143
|
+
assertion(x, '2V')
|
|
144
|
+
self.assertRaises(ValueError, int, *[x], **{}) # deprecated function int(IDstring)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@contextmanager
|
|
148
|
+
def weird_alphabet(self, weird):
|
|
149
|
+
keep = IDstring.ALPHABET
|
|
150
|
+
IDstring.ALPHABET = weird
|
|
151
|
+
try:
|
|
152
|
+
yield None
|
|
153
|
+
finally:
|
|
154
|
+
IDstring.ALPHABET = keep
|
|
155
|
+
|
|
156
|
+
def test6b(self):
|
|
157
|
+
# change the class alphabet to hexadecimal
|
|
158
|
+
with self.weird_alphabet('0123456789ABCDEF'):
|
|
159
|
+
# put a checksum on a hexadecimal number
|
|
160
|
+
f = IDstring(seed='7FFF')
|
|
161
|
+
assertion(f, '7FFFC')
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class Test7(unittest.TestCase):
|
|
165
|
+
# Testing hash
|
|
166
|
+
def test7a(self):
|
|
167
|
+
#test building a factory with a variant hash
|
|
168
|
+
fact = IDstring(None, '90a', '1234', dummy, hash='0')
|
|
169
|
+
#value comes back unchanged
|
|
170
|
+
assertion(fact, '90A1234Y', None)
|
|
171
|
+
IDstring.sumcheck(fact, hash='0')
|
|
172
|
+
#try the next value
|
|
173
|
+
x = fact + 1
|
|
174
|
+
assertion(x, '90B1234X', '90B')
|
|
175
|
+
|
|
176
|
+
def test7b(self):
|
|
177
|
+
#test the carry
|
|
178
|
+
fact = IDstring(None, '000Y', 'ppp', dummy, '0')
|
|
179
|
+
x = fact + 1
|
|
180
|
+
assertion(x, '0010PPP2', '0010')
|
|
181
|
+
|
|
182
|
+
def test7c(self):
|
|
183
|
+
# test the checksum interface
|
|
184
|
+
assert IDstring.sumcheck('TESTME29', hash='0'), 'valid checksum shown as invalid'
|
|
185
|
+
try:
|
|
186
|
+
assert IDstring('TESTME39', hash='0'), 'invalid checksum should not pass'
|
|
187
|
+
except InvalidIdError:
|
|
188
|
+
pass
|
|
189
|
+
else:
|
|
190
|
+
self.fail('Did not see OutOfRangeError')
|
|
191
|
+
|
|
192
|
+
def test7d(self):
|
|
193
|
+
assert not IDstring.sumcheck('TESTME29'), 'invalid checksum should not pass (default hash)'
|
|
194
|
+
|
|
195
|
+
def test7e(self):
|
|
196
|
+
assert not IDstring.sumcheck('TESTME29', hash='XX'), 'invalid checksum should not pass (different hash)'
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class Test8(unittest.TestCase):
|
|
200
|
+
# Testing with no checksum (hash=None)
|
|
201
|
+
def test8a(self):
|
|
202
|
+
#test building a factory with a null hash
|
|
203
|
+
fact = IDstring(None, '5GA', '1234', dummy, None)
|
|
204
|
+
#value comes back unchanged
|
|
205
|
+
assertion(fact, '5GA1234', None)
|
|
206
|
+
IDstring.sumcheck(fact, hash=None)
|
|
207
|
+
#try the next value
|
|
208
|
+
x = fact + 1
|
|
209
|
+
assertion(x, '5GB1234', '5GB')
|
|
210
|
+
|
|
211
|
+
def test8b(self):
|
|
212
|
+
x = IDstring('ADD', seedstore=dummy, hash=None, alphabet='abcd', case_shift=str.lower)
|
|
213
|
+
x += 1
|
|
214
|
+
assertion(x, 'baa', 'baa')
|
|
215
|
+
|
|
216
|
+
x = IDstring(seed='DDDD', seedstore=dummy, hash=None, alphabet='ABCD')
|
|
217
|
+
x += 1
|
|
218
|
+
assertion(x, 'AAAAA')
|
|
219
|
+
|
|
220
|
+
self.assertFalse(IDstring.sumcheck('ABAD1', hash=None, alphabet='ABCD'))
|
|
221
|
+
|
|
222
|
+
class Test9(unittest.TestCase):
|
|
223
|
+
# testing that case_shift=None will not shift case
|
|
224
|
+
def test9(self):
|
|
225
|
+
x = IDstring(seed='AbC', seedstore=dummy, hash=None, alphabet='ABCabc', case_shift=None)
|
|
226
|
+
assertion(x, 'AbC')
|
|
227
|
+
x += 1
|
|
228
|
+
assertion(x, 'Aba')
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class Test10(unittest.TestCase):
|
|
232
|
+
# Test the dirty word filter in more depth
|
|
233
|
+
@contextmanager
|
|
234
|
+
def weird_words(self, weird):
|
|
235
|
+
keep = IDstring.DIRTY_WORDS
|
|
236
|
+
IDstring.DIRTY_WORDS = weird
|
|
237
|
+
try:
|
|
238
|
+
yield None
|
|
239
|
+
finally:
|
|
240
|
+
IDstring.DIRTY_WORDS = keep
|
|
241
|
+
|
|
242
|
+
def test10(self):
|
|
243
|
+
# try changing the dirty word list
|
|
244
|
+
more_words = idstring.DEFAULT_DIRTY_WORDS + idstring.DIRTY_I_WORDS
|
|
245
|
+
with self.weird_words(more_words):
|
|
246
|
+
f = IDstring(seed='tBtist', alphabet='aBcit', case_shift=None, hash=None) # a short mixed case alphabet
|
|
247
|
+
f += 1 # carry should spell a three letter objectionabe word
|
|
248
|
+
assertion(f, 'tBtiaa') # The second "t" should be incremented to "a"
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def test11(self):
|
|
252
|
+
# test carry out of range with alternate alphabet
|
|
253
|
+
f = IDstring(seed='zzz', alphabet='abcz', case_shift=None)
|
|
254
|
+
f += 1
|
|
255
|
+
assertion(f, 'aaaaa')
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
if __name__ == "__main__":
|
|
259
|
+
unittest.main()
|
idstring-2.0.3/MANIFEST.in
DELETED
idstring-2.0.3/PKG-INFO
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: idstring
|
|
3
|
-
Version: 2.0.3
|
|
4
|
-
Summary: a class for compact alpha-numeric serial numbers with (an optional) check digit
|
|
5
|
-
Home-page: https://github.com/vernondcole/idstring
|
|
6
|
-
Author: Vernon Cole
|
|
7
|
-
Author-email: vernondcole@gmail.com
|
|
8
|
-
License: GPL
|
|
9
|
-
Keywords: serial number string checksum
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
|
|
14
|
-
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Natural Language :: English
|
|
17
|
-
Classifier: Operating System :: OS Independent
|
|
18
|
-
Classifier: Topic :: Software Development
|
|
19
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
-
|
|
21
|
-
an IDstring is a string-like object which can be incremented, to produce
|
|
22
|
-
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
23
|
-
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
24
|
-
an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
25
|
-
|
|
26
|
-
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
27
|
-
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
28
|
-
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
29
|
-
|
|
30
|
-
The class will also perform generic binary to alpha conversions in your alphabet (base-32 for the default).
|
|
31
|
-
|
|
32
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: idstring
|
|
3
|
-
Version: 2.0.3
|
|
4
|
-
Summary: a class for compact alpha-numeric serial numbers with (an optional) check digit
|
|
5
|
-
Home-page: https://github.com/vernondcole/idstring
|
|
6
|
-
Author: Vernon Cole
|
|
7
|
-
Author-email: vernondcole@gmail.com
|
|
8
|
-
License: GPL
|
|
9
|
-
Keywords: serial number string checksum
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
|
|
14
|
-
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Natural Language :: English
|
|
17
|
-
Classifier: Operating System :: OS Independent
|
|
18
|
-
Classifier: Topic :: Software Development
|
|
19
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
-
|
|
21
|
-
an IDstring is a string-like object which can be incremented, to produce
|
|
22
|
-
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
23
|
-
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
24
|
-
an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
25
|
-
|
|
26
|
-
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
27
|
-
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
28
|
-
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
29
|
-
|
|
30
|
-
The class will also perform generic binary to alpha conversions in your alphabet (base-32 for the default).
|
|
31
|
-
|
|
32
|
-
|
idstring-2.0.3/setup.cfg
DELETED
idstring-2.0.3/setup.py
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
ld = """an IDstring is a string-like object which can be incremented, to produce
|
|
4
|
-
a series of serial-number-like strings, consisting of Arabic digits and upper case letters,
|
|
5
|
-
skipping those which can be easily misinterpreted ("oh", "I", "Q", and Zed) and which has
|
|
6
|
-
an optional Luhn-N check digit, capable of detecting any single-letter error and most other errors.
|
|
7
|
-
|
|
8
|
-
Programmers may define alternate alphabets, alternate lists of "dirty" words (which are skipped),
|
|
9
|
-
a fixed subfield for generating serial number from multiple sources, and a hash code to create unique check
|
|
10
|
-
digits algorithms for multiple projects. Passing a hash code of None will surpress check digit operation.
|
|
11
|
-
|
|
12
|
-
The class will also perform generic binary to alpha conversions in your alphabet (base-32 for the default).
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
VERSION = None # in case searching for version fails
|
|
16
|
-
a = open("idstring.py") # find the version string in the source code
|
|
17
|
-
for line in a:
|
|
18
|
-
if "__version__" in line:
|
|
19
|
-
VERSION = line.split('"')[1]
|
|
20
|
-
print('idstring version="%s"' % VERSION)
|
|
21
|
-
break
|
|
22
|
-
a.close()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def setup_package():
|
|
26
|
-
from setuptools import setup
|
|
27
|
-
from setuptools.command.build_py import build_py
|
|
28
|
-
|
|
29
|
-
setup(
|
|
30
|
-
cmdclass={"build_py": build_py},
|
|
31
|
-
name = 'idstring',
|
|
32
|
-
version = VERSION,
|
|
33
|
-
author = "Vernon Cole",
|
|
34
|
-
author_email = "vernondcole@gmail.com",
|
|
35
|
-
description = "a class for compact alpha-numeric serial numbers with (an optional) check digit",
|
|
36
|
-
long_description = ld,
|
|
37
|
-
license = "GPL",
|
|
38
|
-
keywords = "serial number string checksum",
|
|
39
|
-
classifiers = [
|
|
40
|
-
'Development Status :: 5 - Production/Stable',
|
|
41
|
-
'Intended Audience :: Developers',
|
|
42
|
-
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
|
|
43
|
-
'Programming Language :: Python',
|
|
44
|
-
'Programming Language :: Python :: 3',
|
|
45
|
-
'Natural Language :: English',
|
|
46
|
-
'Operating System :: OS Independent',
|
|
47
|
-
'Topic :: Software Development',
|
|
48
|
-
'Topic :: Software Development :: Libraries :: Python Modules'],
|
|
49
|
-
url = 'https://github.com/vernondcole/idstring',
|
|
50
|
-
py_modules=["idstring"]
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
if __name__ == '__main__':
|
|
54
|
-
setup_package()
|
|
File without changes
|
|
File without changes
|