-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathREADME
64 lines (47 loc) · 1.34 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
python-kennitala
================
python-kennitala is a python library for common operations on Icelandic
National Registry codes -
`kennitala <https://en.wikipedia.org/wiki/Kennitala>`_.
Capabilities
------------
- Validation of kennitala
- Extraction of birth date from kennitala
- Generating kennitala for a given birth date (for people or companies)
- Generating random kennitala (for people or companies)
- Recognize if kennitala belongs to person or company
Usage
-----
::
>>> from datetime import date
>>> from kennitala import Kennitala
>>>
>>> kt_no = '0101109639'
>>> kennitala = Kennitala(kt_no)
>>> kennitala.validate()
True
>>> kennitala.get_birth_date()
datetime.date(1910, 1, 1)
>>> kennitala = Kennitala(kt_no.replace('3', '4'))
>>> kennitala.validate()
False
>>> kennitala.get_birht_date()
Traceback (most recent call last):
File kennitala.py, in get_birth_date
kennitala.Invalid
>>>
>>> company_kt = Kennitala.generate(date.today(), person=False)
>>> Kennitala.is_personal(company_kt)
False
Installation
------------
inside your virtualenv execute:
::
$ pip install kennitala
or download and install manually.
Tests
-----
Tests are written for `py.test <https://pytest.org/latest>`_
To run tests simply execute:
::
$ PYTHONPATH=./ py.test tests