remapdict
Really simple Python function for arbitrarily remapping dictionary keys value pairs with arbitrary transformations and convenience configuration like passthrough and error handling.
Documentation
Example usage:
user = {
'email': 'email@email.com',
'firstName': 'Foo',
'lastName': 'Bar',
'status': 'active',
'type': 'administrator',
'tenantId': 1,
}
payload = remap_dict(user,
const={'password': 'password'},
passthrough={
'email',
'status',
'type',
},
mapper={
'first_name': 'firstName',
'last_name': 'lastName',
'tenant_id': 'tenantId',
},
transformer={
'full_name': lambda x: f'{x["firstName"]} {x["lastName"]}'
}
)
>>> payload
{
'status': 'active',
'email': 'email@email.com',
'type': 'administrator',
'password': 'password',
'first_name': 'Foo',
'last_name': 'Bar',
'tenant_id': 1,
'full_name': 'Foo Bar'
}
Release files for remapdict 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| remapdict-0.1.1.tar.gz | 1.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| remapdict-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.6 kB
Release files / remapdict-0.1.1.tar.gz
| Download URL | remapdict-0.1.1.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acf5980bf2b86b3553fcc7b8dd207a221ebf52ec30c85a1cd14ca23ed69076d3
|
|
BLAKE2b-256 checksum How to use checksums |
70dafbcbb256b9c649b80d25a4433ab28c049461c6d5711b4559d8eeb3bb9b04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / remapdict-0.1.1-py3-none-any.whl
| Download URL | remapdict-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbe7238505148bc6d80bcb89e20742e2ec0a113ec5336420222544da243195fd
|
|
BLAKE2b-256 checksum How to use checksums |
55565dd363fcb63d692cf2a2e1b4ed808747e9ebeca1988c758b6ce878fd2797
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|