Coded statement of Account (CODA) python API
Project description
# pycoda
[![CircleCI](https://circleci.com/gh/mhemeryck/pycoda.svg?style=svg)](https://circleci.com/gh/mhemeryck/pycoda)
[![Coverage Status](https://coveralls.io/repos/github/mhemeryck/pycoda/badge.svg)](https://coveralls.io/github/mhemeryck/pycoda)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
## Quickstart
Generate a CODA file from a factory:
```python
>>> from pycoda.factories import CodaFileFactory
>>> coda_file = CodaFileFactory()
>>> print coda_file.dumps()
0000029050288805 TWlscjlKSUAnthony Hicks GKCCBEBB 06141120086 2
10000 0000000026785942011208 000
2121170000 0000000700448471091015000000000 15030900000 0
8000 0000000000000000160417 0
9 134803000000336605556000000724123462 2
```
Check the values of the first record:
```python
>>> coda_file.records[0].field_dict()
{'account_holder_reference': 61411200863,
'addressee': u'Anthony Hicks',
'application_code': u'05',
'bank_identification_number': 888,
'bic': u'GKCCBEBB',
'creation_date': datetime.date(2002, 5, 29),
'duplicate': False,
'empty': None,
'free': None,
'identification': 0,
'reference': u'TWlscjlKSU',
'related_reference': None,
'transaction_reference': None,
'version_code': 2,
'zeroes': None}
```
Update a named field of the first record:
```python
>>> coda_file.records[0].addressee = u'John Doe'
>>> print coda_file.records[0].dumps()
0000029050288805 TWlscjlKSUJohn Doe GKCCBEBB 06141120086 2
```
Make a new CODA file object and load the records / fields from the previous object string representation:
```python
>>> plain = coda_file.dumps()
>>> from pycoda.codafile import CodaFile
>>> new_coda = CodaFile()
>>> new_coda.loads(plain)
>>> print new_coda.dumps()
0000029050288805 TWlscjlKSUJohn Doe GKCCBEBB 06141120086 2
10000 0000000026785942011208 000
2121170000 0000000700448471091015000000000 15030900000 0
8000 0000000000000000160417 0
9 134803000000336605556000000724123462 2
>>> new_coda.dumps() == coda_file.dumps()
True
```
## Model
The following model hierarchy is employed:
* CODA file: can consist of multiple records of given type
* Record type: each of the record types hold different specified named fields of given type
* Field type: the fields hold the actual values. All the parsing / printing footwork is done at this level
For each of those levels, the objects can:
* loads: set value from string representation
* dumps: generate string representation from value
[![CircleCI](https://circleci.com/gh/mhemeryck/pycoda.svg?style=svg)](https://circleci.com/gh/mhemeryck/pycoda)
[![Coverage Status](https://coveralls.io/repos/github/mhemeryck/pycoda/badge.svg)](https://coveralls.io/github/mhemeryck/pycoda)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
## Quickstart
Generate a CODA file from a factory:
```python
>>> from pycoda.factories import CodaFileFactory
>>> coda_file = CodaFileFactory()
>>> print coda_file.dumps()
0000029050288805 TWlscjlKSUAnthony Hicks GKCCBEBB 06141120086 2
10000 0000000026785942011208 000
2121170000 0000000700448471091015000000000 15030900000 0
8000 0000000000000000160417 0
9 134803000000336605556000000724123462 2
```
Check the values of the first record:
```python
>>> coda_file.records[0].field_dict()
{'account_holder_reference': 61411200863,
'addressee': u'Anthony Hicks',
'application_code': u'05',
'bank_identification_number': 888,
'bic': u'GKCCBEBB',
'creation_date': datetime.date(2002, 5, 29),
'duplicate': False,
'empty': None,
'free': None,
'identification': 0,
'reference': u'TWlscjlKSU',
'related_reference': None,
'transaction_reference': None,
'version_code': 2,
'zeroes': None}
```
Update a named field of the first record:
```python
>>> coda_file.records[0].addressee = u'John Doe'
>>> print coda_file.records[0].dumps()
0000029050288805 TWlscjlKSUJohn Doe GKCCBEBB 06141120086 2
```
Make a new CODA file object and load the records / fields from the previous object string representation:
```python
>>> plain = coda_file.dumps()
>>> from pycoda.codafile import CodaFile
>>> new_coda = CodaFile()
>>> new_coda.loads(plain)
>>> print new_coda.dumps()
0000029050288805 TWlscjlKSUJohn Doe GKCCBEBB 06141120086 2
10000 0000000026785942011208 000
2121170000 0000000700448471091015000000000 15030900000 0
8000 0000000000000000160417 0
9 134803000000336605556000000724123462 2
>>> new_coda.dumps() == coda_file.dumps()
True
```
## Model
The following model hierarchy is employed:
* CODA file: can consist of multiple records of given type
* Record type: each of the record types hold different specified named fields of given type
* Field type: the fields hold the actual values. All the parsing / printing footwork is done at this level
For each of those levels, the objects can:
* loads: set value from string representation
* dumps: generate string representation from value
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codapy-0.3.5.tar.gz
(8.3 kB
view details)
Built Distribution
codapy-0.3.5-py3-none-any.whl
(10.2 kB
view details)
File details
Details for the file codapy-0.3.5.tar.gz
.
File metadata
- Download URL: codapy-0.3.5.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 565a1c65043bd2a616f49d2023758f1ec963efd25cfcd23970d3d68289e59570 |
|
MD5 | c3c8f841c9790bdd21ca8aecff1fd01f |
|
BLAKE2b-256 | 3bf147867fbdd0d6f8787265f7ddb4360c4630d700d7e6969b0a14318aa2c5f1 |
File details
Details for the file codapy-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: codapy-0.3.5-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faa9b47a5a26d4588090f42f9b549df22622c413077896c50cbea3597dd48933 |
|
MD5 | f0acdaad0eb62188f0d84ea3bbede876 |
|
BLAKE2b-256 | e6e35836fafcc871d9deedae7ce516209f4d401635dcca5766e79daeab071e12 |