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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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