configdict


Nameconfigdict JSON
Version 2.10.2 PyPI version JSON
download
home_page
SummaryA supercharged dict used as configuration
upload_time2024-03-14 08:51:52
maintainer
docs_urlNone
author
requires_python>=3.9
licenseCopyright (c) 2011-2017 GitHub Inc. 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
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            configdict
==========

Documentation
-------------

https://configdict.readthedocs.io


Installation
------------


    $ pip install configdict



CheckedDict
-----------

A dictionary based on a default prototype. A CheckedDict can only define
``key:value`` pairs which are already present in the default. It is possible to
define a docstring for each key and different restrictions for the values
regarding possible values, ranges and type. A CheckedDict is useful for
configuration settings.


ConfigDict
----------

Based on CheckedDict, a ConfigDict is a persistent, unique dictionary. It is
saved under the config folder determined by the OS and it is updated with each
modification. It is useful for implementing configuration of a module / library
/ app, where there is a default/initial state and the user needs to be able to
configure global settings which must be persisted between sessions (similar to
the settings in an application)

Example
-------

.. code-block:: python

   config = ConfigDict("myproj.subproj")
   config.addKey("keyA", 10, doc="documentaion of keyA")
   config.addKey("keyB", 0.5, range=(0, 1))
   config.addKey("keyC", "blue", choices=("blue", "red"),
                 doc="documentation of keyC")
   config.load()

Alternatively, a ConfigDict can be created all at once:

.. code-block:: python
                
   config = ConfigDict("myapp",
       default = {
           'font-size': 10.0,
           'font-family': "Monospace",
           'port' : 9100,
       },
       validator = {
           'font-size::range' : (8, 24),
           'port::range' : (9000, 65000),
           'font-family::choices' : {'Roboto', 'Monospace'},
       },
       docs = {
           'port': 'The port number to listen to',
           'font-size': 'The size of the font, in pixels'
       }
   )

This will create the dictionary and load any persisted version. Any saved
modifications will override the default values. Whenever the user changes any
value (via ``config[key] = newvalue``) the dictionary will be saved.

In all other respects a ConfigDict behaves like a normal dictionary.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "configdict",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Eduardo Moguillansky <eduardo.moguillansky@gmail.com>",
    "download_url": "",
    "platform": null,
    "description": "configdict\n==========\n\nDocumentation\n-------------\n\nhttps://configdict.readthedocs.io\n\n\nInstallation\n------------\n\n\n    $ pip install configdict\n\n\n\nCheckedDict\n-----------\n\nA dictionary based on a default prototype. A CheckedDict can only define\n``key:value`` pairs which are already present in the default. It is possible to\ndefine a docstring for each key and different restrictions for the values\nregarding possible values, ranges and type. A CheckedDict is useful for\nconfiguration settings.\n\n\nConfigDict\n----------\n\nBased on CheckedDict, a ConfigDict is a persistent, unique dictionary. It is\nsaved under the config folder determined by the OS and it is updated with each\nmodification. It is useful for implementing configuration of a module / library\n/ app, where there is a default/initial state and the user needs to be able to\nconfigure global settings which must be persisted between sessions (similar to\nthe settings in an application)\n\nExample\n-------\n\n.. code-block:: python\n\n   config = ConfigDict(\"myproj.subproj\")\n   config.addKey(\"keyA\", 10, doc=\"documentaion of keyA\")\n   config.addKey(\"keyB\", 0.5, range=(0, 1))\n   config.addKey(\"keyC\", \"blue\", choices=(\"blue\", \"red\"),\n                 doc=\"documentation of keyC\")\n   config.load()\n\nAlternatively, a ConfigDict can be created all at once:\n\n.. code-block:: python\n                \n   config = ConfigDict(\"myapp\",\n       default = {\n           'font-size': 10.0,\n           'font-family': \"Monospace\",\n           'port' : 9100,\n       },\n       validator = {\n           'font-size::range' : (8, 24),\n           'port::range' : (9000, 65000),\n           'font-family::choices' : {'Roboto', 'Monospace'},\n       },\n       docs = {\n           'port': 'The port number to listen to',\n           'font-size': 'The size of the font, in pixels'\n       }\n   )\n\nThis will create the dictionary and load any persisted version. Any saved\nmodifications will override the default values. Whenever the user changes any\nvalue (via ``config[key] = newvalue``) the dictionary will be saved.\n\nIn all other respects a ConfigDict behaves like a normal dictionary.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2011-2017 GitHub Inc.  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 supercharged dict used as configuration",
    "version": "2.10.2",
    "project_urls": {
        "Homepage": "https://github.com/gesellkammer/configdict"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9acce58b16760777ebafa1714936f9bbeaeb2c65fafd4046892c37393da26835",
                "md5": "79c5f848da2ff1a47e292ad8bc1d8be9",
                "sha256": "65769c00c697818aa335a5cef2a0508548b7953e81fffd1054b06cb68c98c467"
            },
            "downloads": -1,
            "filename": "configdict-2.10.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79c5f848da2ff1a47e292ad8bc1d8be9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 33369,
            "upload_time": "2024-03-14T08:51:52",
            "upload_time_iso_8601": "2024-03-14T08:51:52.713553Z",
            "url": "https://files.pythonhosted.org/packages/9a/cc/e58b16760777ebafa1714936f9bbeaeb2c65fafd4046892c37393da26835/configdict-2.10.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-14 08:51:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gesellkammer",
    "github_project": "configdict",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "configdict"
}
        
Elapsed time: 0.21614s