Name | dotmapdict JSON |
Version |
1.0.0
JSON |
| download |
home_page | https://github.com/m-sarabi/dotmapdict |
Summary | A dictionary that supports dot notation access |
upload_time | 2024-08-26 23:20:17 |
maintainer | None |
docs_url | None |
author | Mohammad Sarabi |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2024 Mohammad Sarabi 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 |
dictionary
dot notation
access
nested
dot
dict
dotdict
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# dotmapdict
`dotmapdict` is a Python package that enhances the standard dictionary with dot notation access. This makes it easier to work with nested dictionaries by allowing you to access and modify their elements using attribute-style access.
## Features
- **Dot Notation Access**: Access dictionary keys as attributes.
- **Nested Dictionary Handling**: Automatically converts nested dictionaries into `DotDict` instances.
- **Merge Support**: Merge another dictionary into the existing `DotDict`.
- **Flexible Updates**: Update dictionary keys with dot notation.
- **Convert to Standard Dictionary**: Easily convert `DotDict` instances back to standard Python dictionaries.
- **Full Unit Test Coverage**: Comprehensive tests ensure the robustness of `dotmapdict`.
## Installation
Install `dotmapdict` via pip:
```bash
pip install dotmapdict
```
Usage
Here's a basic example of how to use dotmapdict:
```python
from dotmapdict import DotDict
# Initialize a DotDict instance with nested dictionaries
config = DotDict({"database": {"host": "localhost", "port": 5432}}, debug=True)
# Access values using dot notation
print(config.database.host) # Output: localhost
print(config.debug) # Output: True
# Update values using dot notation
config.database.username = "admin"
print(config.database.username) # Output: admin
# Convert back to a standard dictionary
# Output: {'database': {'host': 'localhost', 'port': 5432, 'username': 'admin'}, 'debug': True}
print(config.to_dict())
print(type(config.to_dict())) # Output: <class 'dict'>
# Merge another dictionary into the existing DotDict
config.merge({"database": {"password": "secret"}})
print(config.database.password) # Output: secret
# Update the DotDict with another dictionary
config.update({"database": {"port": 5433, "ssl": False}})
print(config.database.port) # Output: 5433
print(config.database.ssl) # Output: False
# Delete a value using dot notation
del config.database.username
del config.database.port
print(config.database.username) # Output: None
print(config.database) # Output: {'host': 'localhost', 'password': 'secret', 'ssl': False}
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contact
For any inquiries or issues, create an [issue](https://github.com/m-sarabi/dotmapdict/issues)
Raw data
{
"_id": null,
"home_page": "https://github.com/m-sarabi/dotmapdict",
"name": "dotmapdict",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "dictionary, dot notation, access, nested, dot, dict, dotdict",
"author": "Mohammad Sarabi",
"author_email": "Mohammad Sarabi <m.sarabi.jkd@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/82/d4/ec880c1fd0257e4bba341704be34c50019cfb7e83abcf3a9dc1da1337a8d/dotmapdict-1.0.0.tar.gz",
"platform": null,
"description": "# dotmapdict\r\n\r\n`dotmapdict` is a Python package that enhances the standard dictionary with dot notation access. This makes it easier to work with nested dictionaries by allowing you to access and modify their elements using attribute-style access.\r\n\r\n## Features\r\n\r\n- **Dot Notation Access**: Access dictionary keys as attributes.\r\n- **Nested Dictionary Handling**: Automatically converts nested dictionaries into `DotDict` instances.\r\n- **Merge Support**: Merge another dictionary into the existing `DotDict`.\r\n- **Flexible Updates**: Update dictionary keys with dot notation.\r\n- **Convert to Standard Dictionary**: Easily convert `DotDict` instances back to standard Python dictionaries.\r\n- **Full Unit Test Coverage**: Comprehensive tests ensure the robustness of `dotmapdict`.\r\n\r\n## Installation\r\n\r\nInstall `dotmapdict` via pip:\r\n\r\n```bash\r\npip install dotmapdict\r\n```\r\n\r\nUsage\r\nHere's a basic example of how to use dotmapdict:\r\n\r\n```python\r\nfrom dotmapdict import DotDict\r\n\r\n# Initialize a DotDict instance with nested dictionaries\r\nconfig = DotDict({\"database\": {\"host\": \"localhost\", \"port\": 5432}}, debug=True)\r\n\r\n# Access values using dot notation\r\nprint(config.database.host) # Output: localhost\r\nprint(config.debug) # Output: True\r\n\r\n# Update values using dot notation\r\nconfig.database.username = \"admin\"\r\nprint(config.database.username) # Output: admin\r\n\r\n# Convert back to a standard dictionary\r\n# Output: {'database': {'host': 'localhost', 'port': 5432, 'username': 'admin'}, 'debug': True}\r\nprint(config.to_dict())\r\nprint(type(config.to_dict())) # Output: <class 'dict'>\r\n\r\n# Merge another dictionary into the existing DotDict\r\nconfig.merge({\"database\": {\"password\": \"secret\"}})\r\nprint(config.database.password) # Output: secret\r\n\r\n# Update the DotDict with another dictionary\r\nconfig.update({\"database\": {\"port\": 5433, \"ssl\": False}})\r\nprint(config.database.port) # Output: 5433\r\nprint(config.database.ssl) # Output: False\r\n\r\n# Delete a value using dot notation\r\ndel config.database.username\r\ndel config.database.port\r\nprint(config.database.username) # Output: None\r\nprint(config.database) # Output: {'host': 'localhost', 'password': 'secret', 'ssl': False}\r\n```\r\n\r\n## License\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Contact\r\nFor any inquiries or issues, create an [issue](https://github.com/m-sarabi/dotmapdict/issues)\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Mohammad Sarabi 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. ",
"summary": "A dictionary that supports dot notation access",
"version": "1.0.0",
"project_urls": {
"Changelog": "https://github.com/m-sarabi/dotmapdict/blob/main/CHANGELOG.MD",
"Documentation": "https://github.com/m-sarabi/dotmapdict",
"Homepage": "https://github.com/m-sarabi/dotmapdict",
"Issues": "https://github.com/m-sarabi/dotmapdict/issues",
"Repository": "https://github.com/m-sarabi/dotmapdict"
},
"split_keywords": [
"dictionary",
" dot notation",
" access",
" nested",
" dot",
" dict",
" dotdict"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b9e25ab01a0570a7082fce4cdd022926b5bfb688b7753c6662c661ac9bf3c46d",
"md5": "94d85fb1a0080caed1f4e37bbfcf69da",
"sha256": "4207bf78cc287060b7b14dcddb96c5b0f7f6c2f1f80a911a81b1d8eabeea1c67"
},
"downloads": -1,
"filename": "dotmapdict-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "94d85fb1a0080caed1f4e37bbfcf69da",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4376,
"upload_time": "2024-08-26T23:20:15",
"upload_time_iso_8601": "2024-08-26T23:20:15.742604Z",
"url": "https://files.pythonhosted.org/packages/b9/e2/5ab01a0570a7082fce4cdd022926b5bfb688b7753c6662c661ac9bf3c46d/dotmapdict-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "82d4ec880c1fd0257e4bba341704be34c50019cfb7e83abcf3a9dc1da1337a8d",
"md5": "abfc82a14ab4f2a6d29d169174679e87",
"sha256": "8ce282c529a951b490676cb709c0a211d9d8cbb470215d21b6354adbf890c913"
},
"downloads": -1,
"filename": "dotmapdict-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "abfc82a14ab4f2a6d29d169174679e87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4087,
"upload_time": "2024-08-26T23:20:17",
"upload_time_iso_8601": "2024-08-26T23:20:17.429467Z",
"url": "https://files.pythonhosted.org/packages/82/d4/ec880c1fd0257e4bba341704be34c50019cfb7e83abcf3a9dc1da1337a8d/dotmapdict-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-26 23:20:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "m-sarabi",
"github_project": "dotmapdict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "dotmapdict"
}