Skip to main content

Python library for easy-to-read conversion of a dictionary to a string and pretty printing.

Project description

Dictppr

Release Min. Python version License GPLv3 Code quality Tests

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dictppr-1.0.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

dictppr-1.0.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file dictppr-1.0.0.tar.gz.

File metadata

  • Download URL: dictppr-1.0.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for dictppr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1a45c045fe9e591f219fa589117100c602ace90465573301e9b31b64e883bbcb
MD5 e12a1c140be6490faa7c502334855025
BLAKE2b-256 faf49d6084da372e2167ebe32c7044de5c99483a2b93df76e66623c4c06ee05c

See more details on using hashes here.

File details

Details for the file dictppr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dictppr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for dictppr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c05f17a238938e879d7dba2589b0f08cbfcf830a30d78100c4df174125bd2b5
MD5 cc7d74c2caba3481203696721cc02151
BLAKE2b-256 3bb0f828f1b3c6f543666ae1054c1e63917834eba0807ed5188ef68d5353ba8e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page