Skip to main content

DICT-OPERATION allow you select data value from a dict-instance with dot separated path, and update.

Project description

dictop

DICT-OPERATION allow you select data value from a dict-instance with dot separated path, and update.

Install

pip install dictop

Test Passed On Python

  • 2.7
  • 3.2
  • 3.3
  • 3.4
  • 3.5
  • 3.6
  • 3.7
  • 3.8
  • 3.9
  • 3.10
  • 3.11

Usage

    from dictop import update
    from dictop import select

    data = {}
    update(data, "a.b.c", 2)
    assert select(data, "a.b.c") == 2

Core Functions

  1. select
    select(target, path, default=None, slient=True)
  1. update
    update(target, path, value)

Unit Tests

# tests.py

import unittest
import dictop

class DictopTest(unittest.TestCase):


    def test01(self):
        data = {
            "a": {
                "b": "value",
            }
        }
        assert dictop.select(data, "a.b") == "value"
        assert dictop.select(data, "a.c") is None
    
    def test02(self):
        data = {
            "a": [{
                "b": "value",
            }]
        }
        assert dictop.select(data, "a.0.b") == "value"
        assert dictop.select(data, "a.1.b") is None

    def test03(self):
        data = [1,2,3]
        assert dictop.select(data, "0") == 1
        assert dictop.select(data, "4") is None

    def test04(self):
        data = {}
        dictop.update(data, "a.b.c", "value")
        dictop.select(data, "a.b.c") == "value"
    
    def test05(self):
        data = []
        dictop.update(data, "1.a.b", "value")
        assert data[1]["a"]["b"] == "value"

Releases

0.1.0 2018/03/20

  • First release.

0.1.1 2018/03/20

0.1.2 2018/04/02

0.1.3 2018/04/18

0.1.4 2019/04/12

  • Update.

0.2.1 2022/01/08

  • Fix license file missing problem.

0.2.2 2023/09/08

  • Add gitlab-ci and tested on all python versions.

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

dictop-0.2.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

dictop-0.2.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file dictop-0.2.2.tar.gz.

File metadata

  • Download URL: dictop-0.2.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dictop-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4cbd879f8c1b61e787f90ee1ba928efdb1a0feb114982053b5fc8625dc03a3b3
MD5 90fa391a478b2c999e0c928d5dedf01f
BLAKE2b-256 fbfb7aa797b7583364feb52329a6d039d9991158848704ecd6816a5d6ded00b4

See more details on using hashes here.

File details

Details for the file dictop-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: dictop-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dictop-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09caf28e0a0863376b4742d6c76e52b0e9a82878a45b0a382dbab2debea99c25
MD5 21110512419ffb3f431e1bffca7dcec3
BLAKE2b-256 8e062f1e58461a9609048c9f72f16354d308c7779b47f73022e814bf9e06dc1e

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