dotc


Namedotc JSON
Version 0.3.5 PyPI version JSON
download
home_pageNone
SummaryDOTC (like Yahtzee) - Access Nested Dicts and Lists via Dots
upload_time2025-09-16 19:26:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2023 soulrx Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords nested dot dict list datastructure dotspace dotdict dotlist xml dotc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dotc
DOTC (like Yahtzee) - Access Nested Dicts and Lists via Dots (Dotc objects all the way down) 

pip install dotc
python
from dotc import Dotc

d1 = Dotc( data={'some':'data'}, node='root or name of data object - defaults to empty string')


# optionally
from dotc import DataPath
dp = DataPath()

Converts Python Data Structures (dicts, lists, scalars) to a nested object structure

    - can access nested data with dot notation and _listindex for lists

      - example:
            data = {'a':1,'b':{'c':3,'d':[4,5,'6']}}
            node = 'root' # optional node name; defaults to '', but child nodes get their names from keys
            o = Dotc(data,node) or o = Dotc(data=data,node='root')
            o.a returns 1
            o.b.c returns 3
            o.b.d._0 returns 4
    
    - if _strict=0 (default), accessing a non-existent attribute returns _default instead of raising AttributeError

      - example using o from above:
            o.b.x returns None (the default _default value)

    - if _strict=1, setting a value on a non-existent path raises an exception

    - if setting _strict=1 after instantiation, it has no effect on child nodes (TODO: fix with @property(s))

    - use ._ to get fully resolved data structure otherwise ._val is the scalar/resultant value if set
        otherwise the Dotc object is returned so you can keep traversing with dot notation

      - example using d from above:
            o._ returns {'a':1,'b':{'c':3,'d':[4,5,'6']}}
            o.b._ returns {'c':3,'d':[4,5,'6']} where as d.b returns the Dotc object itself so that:
            o.b.d._ returns [4,5,'6']

    - explore (using o from above) passing in the dotc object (or not for self) 
        and optionally v for verbosity:
        
        >>> o._show()
        {'_key_ct': 2,
        '_ls_ct': 0,
        '_node': 'root',
        '_parent': None,
        '_strict': 0,
        '_val': None}

        >>> o._show(v=1)
        {'_key_ct': 2,
        '_ls_ct': 0,
        '_node': 'root',
        '_parent': None,
        '_strict': 0,
        '_val': None,
        'a': 1,
        'b': Dotc( "b", _val=None, _key_ct=2, _ls_ct=0 )}

        >>> o._show(o.b.d, v=1)
        {'_0': 4,
        '_1': 5,
        '_2': '6',
        '_key_ct': 0,
        '_ls_ct': 3,
        '_node': 'd',
        '_parent': 'b',
        '_strict': 0,
        '_val': None}

    - backported DataPath which was the original tool used without self dot access for programmatically accessing nested objects
      now it can be used on Dotc objects
      
      - example (using o from above):

        from dotc import DataPath as DP
        
        dp = DP()
        >>> dp.get('b.d',o)
        [4, 5, '6']

        >>> r = dp.get('b.d',o,debug=1)
        DEBUG: getting b from o=Dotc( "root", _val=None, _key_ct=2, _ls_ct=0 )
        DEBUG: getting d from o=Dotc( "b", _val=None, _key_ct=2, _ls_ct=0 )
        DEBUG: final obj: got Dotc object obj=Dotc( "d", _val=None, _key_ct=0, _ls_ct=3 )
        >>> r
        [4, 5, '6']

        >>> dp.get('b.d.2',o,debug=1)
        DEBUG: getting b from o=Dotc( "root", _val=None, _key_ct=2, _ls_ct=0 )
        DEBUG: getting d from o=Dotc( "b", _val=None, _key_ct=2, _ls_ct=0 )
        '6'

        NOTE: '.2' could be used instead of '._2' (required for actual dotc attribute access) as DataPath converts it for dotc objects

        NOTE: Also, DataPath works on other nested datastructures in Python

        >>> dp.get('b.d.2', data, debug=1)
        '6'

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dotc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "nested, dot, dict, list, datastructure, dotspace, dotdict, dotlist, xml, dotc",
    "author": null,
    "author_email": "Mike Steele <mike@mikesteele.us>",
    "download_url": "https://files.pythonhosted.org/packages/3a/42/d405e7bd102020ab12a5943cc040e7960e1500120d8a4de17945d7023a5b/dotc-0.3.5.tar.gz",
    "platform": null,
    "description": "# dotc\nDOTC (like Yahtzee) - Access Nested Dicts and Lists via Dots (Dotc objects all the way down) \n\npip install dotc\npython\nfrom dotc import Dotc\n\nd1 = Dotc( data={'some':'data'}, node='root or name of data object - defaults to empty string')\n\n\n# optionally\nfrom dotc import DataPath\ndp = DataPath()\n\nConverts Python Data Structures (dicts, lists, scalars) to a nested object structure\n\n    - can access nested data with dot notation and _listindex for lists\n\n      - example:\n            data = {'a':1,'b':{'c':3,'d':[4,5,'6']}}\n            node = 'root' # optional node name; defaults to '', but child nodes get their names from keys\n            o = Dotc(data,node) or o = Dotc(data=data,node='root')\n            o.a returns 1\n            o.b.c returns 3\n            o.b.d._0 returns 4\n    \n    - if _strict=0 (default), accessing a non-existent attribute returns _default instead of raising AttributeError\n\n      - example using o from above:\n            o.b.x returns None (the default _default value)\n\n    - if _strict=1, setting a value on a non-existent path raises an exception\n\n    - if setting _strict=1 after instantiation, it has no effect on child nodes (TODO: fix with @property(s))\n\n    - use ._ to get fully resolved data structure otherwise ._val is the scalar/resultant value if set\n        otherwise the Dotc object is returned so you can keep traversing with dot notation\n\n      - example using d from above:\n            o._ returns {'a':1,'b':{'c':3,'d':[4,5,'6']}}\n            o.b._ returns {'c':3,'d':[4,5,'6']} where as d.b returns the Dotc object itself so that:\n            o.b.d._ returns [4,5,'6']\n\n    - explore (using o from above) passing in the dotc object (or not for self) \n        and optionally v for verbosity:\n        \n        >>> o._show()\n        {'_key_ct': 2,\n        '_ls_ct': 0,\n        '_node': 'root',\n        '_parent': None,\n        '_strict': 0,\n        '_val': None}\n\n        >>> o._show(v=1)\n        {'_key_ct': 2,\n        '_ls_ct': 0,\n        '_node': 'root',\n        '_parent': None,\n        '_strict': 0,\n        '_val': None,\n        'a': 1,\n        'b': Dotc( \"b\", _val=None, _key_ct=2, _ls_ct=0 )}\n\n        >>> o._show(o.b.d, v=1)\n        {'_0': 4,\n        '_1': 5,\n        '_2': '6',\n        '_key_ct': 0,\n        '_ls_ct': 3,\n        '_node': 'd',\n        '_parent': 'b',\n        '_strict': 0,\n        '_val': None}\n\n    - backported DataPath which was the original tool used without self dot access for programmatically accessing nested objects\n      now it can be used on Dotc objects\n      \n      - example (using o from above):\n\n        from dotc import DataPath as DP\n        \n        dp = DP()\n        >>> dp.get('b.d',o)\n        [4, 5, '6']\n\n        >>> r = dp.get('b.d',o,debug=1)\n        DEBUG: getting b from o=Dotc( \"root\", _val=None, _key_ct=2, _ls_ct=0 )\n        DEBUG: getting d from o=Dotc( \"b\", _val=None, _key_ct=2, _ls_ct=0 )\n        DEBUG: final obj: got Dotc object obj=Dotc( \"d\", _val=None, _key_ct=0, _ls_ct=3 )\n        >>> r\n        [4, 5, '6']\n\n        >>> dp.get('b.d.2',o,debug=1)\n        DEBUG: getting b from o=Dotc( \"root\", _val=None, _key_ct=2, _ls_ct=0 )\n        DEBUG: getting d from o=Dotc( \"b\", _val=None, _key_ct=2, _ls_ct=0 )\n        '6'\n\n        NOTE: '.2' could be used instead of '._2' (required for actual dotc attribute access) as DataPath converts it for dotc objects\n\n        NOTE: Also, DataPath works on other nested datastructures in Python\n\n        >>> dp.get('b.d.2', data, debug=1)\n        '6'\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 soulrx\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "DOTC (like Yahtzee) - Access Nested Dicts and Lists via Dots",
    "version": "0.3.5",
    "project_urls": {
        "Homepage": "https://github.com/soulrx/dotc"
    },
    "split_keywords": [
        "nested",
        " dot",
        " dict",
        " list",
        " datastructure",
        " dotspace",
        " dotdict",
        " dotlist",
        " xml",
        " dotc"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fbc80bbc878303792c9bbcd1555db23ccef8d64303cd3ecd3381185978f7a4e2",
                "md5": "30aa3bda4edc5f20270f0b651bb0520a",
                "sha256": "4f41bd4bf06986197aa1db32df9ca1f9a9eae6ddad0c7971224645eef0ba70f6"
            },
            "downloads": -1,
            "filename": "dotc-0.3.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30aa3bda4edc5f20270f0b651bb0520a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 498796,
            "upload_time": "2025-09-16T19:26:51",
            "upload_time_iso_8601": "2025-09-16T19:26:51.868787Z",
            "url": "https://files.pythonhosted.org/packages/fb/c8/0bbc878303792c9bbcd1555db23ccef8d64303cd3ecd3381185978f7a4e2/dotc-0.3.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3a42d405e7bd102020ab12a5943cc040e7960e1500120d8a4de17945d7023a5b",
                "md5": "90013a86c47b792b1d99aa5afabdaf76",
                "sha256": "af17d4822ac31a80f1c4b342e9168e0c5f635ad6b1bd52c9130950155ba06ec8"
            },
            "downloads": -1,
            "filename": "dotc-0.3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "90013a86c47b792b1d99aa5afabdaf76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 502369,
            "upload_time": "2025-09-16T19:26:52",
            "upload_time_iso_8601": "2025-09-16T19:26:52.986026Z",
            "url": "https://files.pythonhosted.org/packages/3a/42/d405e7bd102020ab12a5943cc040e7960e1500120d8a4de17945d7023a5b/dotc-0.3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-16 19:26:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "soulrx",
    "github_project": "dotc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dotc"
}
        
Elapsed time: 3.58023s