A convenience function for arbitrarily remapping dictionary keys, taking subsets, etc.
Project description
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'
}
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
remapdict-0.1.0.tar.gz
(2.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remapdict-0.1.0.tar.gz.
File metadata
- Download URL: remapdict-0.1.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b757b17e5c512f3b184c763d62ec705e968cfef27b907b0ee812eaff0db221
|
|
| MD5 |
59a67a420c7535b127598c5996452dd5
|
|
| BLAKE2b-256 |
b61c99c6ee350770cf74172abdb3477aaa333d26cb817058efe9f23c9ac67226
|
File details
Details for the file remapdict-0.1.0-py3-none-any.whl.
File metadata
- Download URL: remapdict-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0d2d8cfa923d40a35b1ebab2b7c454d7a37b11d4455321c4f4e37e9a631f63b
|
|
| MD5 |
76cf61decd2c5e3162d35d44de18b8e1
|
|
| BLAKE2b-256 |
26019d03361efd8ce4e8ed5b3fdbfa3998fd4ddd94d00f42a212d64426824b4f
|