dictop


Namedictop JSON
Version 0.2.2 PyPI version JSON
download
home_page
SummaryDICT-OPERATION allow you select data value from a dict-instance with dot separated path, and update.
upload_time2023-09-08 02:17:05
maintainerChen Qi
docs_urlNone
authorChen Qi
requires_python
licenseMIT
keywords dictop
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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)
```

2. 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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dictop",
    "maintainer": "Chen Qi",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "chenqi@zencore.cn",
    "keywords": "dictop",
    "author": "Chen Qi",
    "author_email": "chenqi@zencore.cn",
    "download_url": "https://files.pythonhosted.org/packages/fb/fb/7aa797b7583364feb52329a6d039d9991158848704ecd6816a5d6ded00b4/dictop-0.2.2.tar.gz",
    "platform": null,
    "description": "# dictop\n\nDICT-OPERATION allow you select data value from a dict-instance with dot separated path, and update.\n\n## Install\n\n```\npip install dictop\n```\n\n## Test Passed On Python\n\n- 2.7\n- 3.2\n- 3.3\n- 3.4\n- 3.5\n- 3.6\n- 3.7\n- 3.8\n- 3.9\n- 3.10\n- 3.11\n\n## Usage\n\n```\n    from dictop import update\n    from dictop import select\n\n    data = {}\n    update(data, \"a.b.c\", 2)\n    assert select(data, \"a.b.c\") == 2\n```\n\n## Core Functions\n\n1. select\n\n```\n    select(target, path, default=None, slient=True)\n```\n\n2. update\n\n```\n    update(target, path, value)\n```\n## Unit Tests\n\n```\n# tests.py\n\nimport unittest\nimport dictop\n\nclass DictopTest(unittest.TestCase):\n\n\n    def test01(self):\n        data = {\n            \"a\": {\n                \"b\": \"value\",\n            }\n        }\n        assert dictop.select(data, \"a.b\") == \"value\"\n        assert dictop.select(data, \"a.c\") is None\n    \n    def test02(self):\n        data = {\n            \"a\": [{\n                \"b\": \"value\",\n            }]\n        }\n        assert dictop.select(data, \"a.0.b\") == \"value\"\n        assert dictop.select(data, \"a.1.b\") is None\n\n    def test03(self):\n        data = [1,2,3]\n        assert dictop.select(data, \"0\") == 1\n        assert dictop.select(data, \"4\") is None\n\n    def test04(self):\n        data = {}\n        dictop.update(data, \"a.b.c\", \"value\")\n        dictop.select(data, \"a.b.c\") == \"value\"\n    \n    def test05(self):\n        data = []\n        dictop.update(data, \"1.a.b\", \"value\")\n        assert data[1][\"a\"][\"b\"] == \"value\"\n```\n\n## Releases\n\n### 0.1.0 2018/03/20\n\n- First release.\n\n### 0.1.1 2018/03/20\n### 0.1.2 2018/04/02\n### 0.1.3 2018/04/18\n### 0.1.4 2019/04/12\n\n- Update.\n\n### 0.2.1 2022/01/08\n\n- Fix license file missing problem.\n\n### 0.2.2 2023/09/08\n\n- Add gitlab-ci and tested on all python versions.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "DICT-OPERATION allow you select data value from a dict-instance with dot separated path, and update.",
    "version": "0.2.2",
    "project_urls": null,
    "split_keywords": [
        "dictop"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e062f1e58461a9609048c9f72f16354d308c7779b47f73022e814bf9e06dc1e",
                "md5": "21110512419ffb3f431e1bffca7dcec3",
                "sha256": "09caf28e0a0863376b4742d6c76e52b0e9a82878a45b0a382dbab2debea99c25"
            },
            "downloads": -1,
            "filename": "dictop-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "21110512419ffb3f431e1bffca7dcec3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3392,
            "upload_time": "2023-09-08T02:17:03",
            "upload_time_iso_8601": "2023-09-08T02:17:03.585436Z",
            "url": "https://files.pythonhosted.org/packages/8e/06/2f1e58461a9609048c9f72f16354d308c7779b47f73022e814bf9e06dc1e/dictop-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbfb7aa797b7583364feb52329a6d039d9991158848704ecd6816a5d6ded00b4",
                "md5": "90fa391a478b2c999e0c928d5dedf01f",
                "sha256": "4cbd879f8c1b61e787f90ee1ba928efdb1a0feb114982053b5fc8625dc03a3b3"
            },
            "downloads": -1,
            "filename": "dictop-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "90fa391a478b2c999e0c928d5dedf01f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3444,
            "upload_time": "2023-09-08T02:17:05",
            "upload_time_iso_8601": "2023-09-08T02:17:05.038983Z",
            "url": "https://files.pythonhosted.org/packages/fb/fb/7aa797b7583364feb52329a6d039d9991158848704ecd6816a5d6ded00b4/dictop-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-08 02:17:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dictop"
}
        
Elapsed time: 1.72222s