Python library for working with Estonian national identity numbers.
Install
Use pip to install:
pip install estnin
Documentation
Full documentation is at https://estnin.readthedocs.io/
Runnig tests
python setup.py test
Usage
Create a new estnin instance:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> print(person.sequence) >>> 123 >>> print(estnin(estnin.MIN)) >>> 10001010002 >>> person = estnin.create(estnin.MALE, date(1970, 1, 1), 1) >>> print(person) >>> 37001010018
str()
>>> assert estnin(37001010018) == "37001010018"
int()
>>> assert estnin(37001010018) == 37001010018
<, ==, >
>>> assert estnin(37001011233) < estnin(estnin.MAX) >>> assert estnin(37001011233) > estnin(estnin.MIN) >>> assert estnin(37001011233) == estnin(37001011233)
negation
Negation is defined as changing the sex from male to female or vice verca.
>>> assert -estnin(37001011233) == estnin(47001011234)
addition and substraction
Adding an integer increments the sequence value by given amount. If the sum of the sequence and the number given is greater than 999, then the day is incremented and the remainder is set as the new sequence value. The day, month and year values are incremented in chronological order until the defined maximum value is reached. If the year crosses the century boundary, then the century digit is also properly set.
>>> assert estnin(37001011244) == estnin(37001011233)+1 >>> assert estnin(37001011244) == estnin(37001011255)-1 >>> # Create new person >>> person = estnin.create(estnin.MALE, date(1999, 12, 31), 999) >>> print(person) >>> 39912319997 >>> assert estnin(50001010006) == person+1
iteration
Iterating over a given estnin instance creates new objects.
>>> people = [p for _, p in zip(range(3), estnin(37001011233))]
>>> print(' '.join(map(str, people)))
>>> 37001011233 37001011244 37001011255
Iterating in a reverse order can be done by using the method reversed():
>>> people = [p for _, p in zip(range(3), reversed(estnin(37001011233)))]
>>> print(' '.join(map(str, people)))
>>> 37001011233 37001011222 37001011211
properties
>>> person = estnin.create(estnin.MALE, date(1970, 1, 2), 3) >>> person 37001020036 >>> person.century 3 >>> person.year 1970 >>> person.month 1 >>> person.day 2 >>> person.sequence 3 >>> person.checksum 6 >>> person.date datetime.date(1970, 1, 2)
Release files for estnin 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| estnin-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / estnin-1.0.1-py3-none-any.whl
| Download URL | estnin-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9136519771adaf743b2dfa7b548d828cb33789a0e8276d37b2f86a49ad236d8
|
|
BLAKE2b-256 checksum How to use checksums |
62c77d7594cb3edc55fd5f22aec379e469cd02fab3cdd42cceb6ddc22af6d9fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
|