Dictppr
A package that allows easy-to-read conversion of a dictionary to a string and pretty printing.
Features
- Convert dictionary to string
- Convert dictionary to dictionary of string
- Pretty print dictionary
Installation
Download the latest version from PyPi
python -m pip install dictppr
Developers should also install tests dependencies
pip install -r requirements_dev.txt
Testing
Perform the tests with pytest (or Tox)
python -m pytest tests
To check test coverage
coverage report -m
Current coverage:
| Name | Stmts | Miss | Cover |
|---|---|---|---|
| dictppr\__init__.py | 3 | 0 | 100% |
| dictppr\dictppr.py | 68 | 1 | 99% |
Usage
First, you need to import the package:
import dictppr
Now, to get string from dictionary:
string = dictppr.get({...})
..or to get dictionary of strings:
dictionary = dictppr.convert({...})
..or you just want to print it:
dictppr.pprint({...})
If you need to check version of dictppr, use:
print(dictppr.__version__)
Examples
You have dictionary like that:
sample = {
"key_1": "val_1",
"key_2": {
"key_3": "val_3",
"key_4": "val_4"
}
}
You will get this string with the get function:
string = "key_1:val_1, key_2:key_3:val_3, key_4:val_4"
You will get this dictionary with the convert function:
dictionary = {"key_1": "val_1", "key_2": "key_3:val_3, key_4:val_4"}
You will get this stdout with the pprint function:
key_1 => val_1
key_2 => key_3:val_3, key_4:val_4
Contributing
Pull requests are welcome!
Metadata
Release files for dictppr 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dictppr-1.0.0.tar.gz | 16.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dictppr-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / dictppr-1.0.0.tar.gz
| Download URL | dictppr-1.0.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a45c045fe9e591f219fa589117100c602ace90465573301e9b31b64e883bbcb
|
|
BLAKE2b-256 checksum How to use checksums |
faf49d6084da372e2167ebe32c7044de5c99483a2b93df76e66623c4c06ee05c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.4.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0
|
Release files / dictppr-1.0.0-py3-none-any.whl
| Download URL | dictppr-1.0.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c05f17a238938e879d7dba2589b0f08cbfcf830a30d78100c4df174125bd2b5
|
|
BLAKE2b-256 checksum How to use checksums |
3bb0f828f1b3c6f543666ae1054c1e63917834eba0807ed5188ef68d5353ba8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.4.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0
|