{ "info": { "author": "Namida Aneskans", "author_email": "namida@skunkfrukt.se", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: Public Domain", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# confjson\n[![Build Status](https://travis-ci.org/skunkfrukt/confjson.svg?branch=master)](https://travis-ci.org/skunkfrukt/confjson)\n## What is it?\nA bafflingly simple, JSON-backed configuration manager for Python programs.\n\n## Why is it?\nI kept implementing roughly the same thing from scratch in my various projects, so I figured it was time to do it properly.\n\n## User guide\nThe `confjson.Config` class is similar to a ChainMap, and works by means of two JSON files in the same directory:\n* `default.config.json`\n - The default config file is read-only as far as confjson is concerned. To add default settings, manually edit the file.\n - If the file does not exist, there are no defaults.\n - This file will typically be version controlled along with the code.\n* `user.config.json`\n - Any changes made to the config (and saved) at runtime end up in this file.\n - If the file does not exist, it will be created when changes are saved.\n - User settings take priority over default settings.\n - This file should probably be added to .gitignore or such.\nThe names of both files are configurable. The above names are the defaults.\n\n### Initialization\nThe path given when initializing the Config object can be either a directory or a file. If it refers to a file, confjson will look for config files in the containing directory. The reason for this is that it enables the pattern of using `__file__` to find config files in the same directory as the program.\n```python\nconfig = confjson.Config(__file__)\nconfig = confjson.Config(\".\")\nconfig = confjson.Config(\n\t\"./configs\",\n\tuser_config_filename=f\"{os.getenv('username')}.cfg\",\n\tdefault_config_filename=\"global.cfg\",\n)\n```\n\n### Data access\nItems in the confjson config are accessed as in a dict.\n```python\nif \"username\" in config[\"user\"]:\n\tdo_something(config[\"user\"][\"username\"])\n\tconfig[\"user\"][\"something_count\"] += 1\n```\nIt is also possible to access items as attributes, *unless they share a name with a method of the Config class*.\n```python\nconfig.my_key = \"my value\"\n```\n\n### Persistence\nThe load() method (re-)loads the Config object with values from the backing JSON files. Loading is also performed on initialization, so this is mainly for discarding changes.\n```python\nconfig.load()\n```\nThe save() method saves any changed or added items **to user.config.json only**.\n```python\nconfig.save()\n```\n\n## Version history\n\n### 1.3.0\n* Made filenames of both user.config.json and default.config.json configurable.\n* Added `use_placeholders` argument to Config class. When True, doesn't raise KeyError on attempted access to a nonexistent key, instead returning a placeholder. Assignments of keys to a placeholder will propagate up through the hierarchy and add real dicts as needed.\n\n### 1.2.2\n* Added `keys()`, `get(key, default)` and `__contains__(key)` to ConfigItemProxy to fix a few problems caused by the previous change.\n\n### 1.2.1\n* Improved attribute-style access and enabled mixed style access.\n\n### 1.2.0\n* Enabled attribute-style access to config items.\n\n### 1.1.0\n* Fixed handling of nested dicts.\n* Added check to prevent insertion of JSON-incompatible values right away rather than fail on save.\n* Added some more dict-like dunder methods.\n\n### 1.0.1\n* Changed `__init__` to also load the config files.\n\n### 1.0.0\n* Initial release.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/skunkfrukt/confjson", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "confjson", "package_url": "https://pypi.org/project/confjson/", "platform": "", "project_url": "https://pypi.org/project/confjson/", "project_urls": { "Homepage": "https://github.com/skunkfrukt/confjson" }, "release_url": "https://pypi.org/project/confjson/1.3.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "A bafflingly simple, JSON-backend configuration manager for python programs.", "version": "1.3.0" }, "last_serial": 4491021, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "2b9290bfcd3b62e9900f32b841602e30", "sha256": "ecdb87b83c096a4990de24a4e3b213627492852805fd71680549bfbadcdeff37" }, "downloads": -1, "filename": "confjson-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2b9290bfcd3b62e9900f32b841602e30", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4249, "upload_time": "2018-10-10T05:38:46", "url": "https://files.pythonhosted.org/packages/f9/f0/a6db8cc73068c974dd3ca0908dfc5f82acbfad38b9b36f0dd2109b54318c/confjson-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e35c045e2ade9fadf9c2e67b64ef80ea", "sha256": "eaa2f811b029329c4a2beb53d4e30343cc22d9ea54eb438e7c10753f2dabcdf1" }, "downloads": -1, "filename": "confjson-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e35c045e2ade9fadf9c2e67b64ef80ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3144, "upload_time": "2018-10-10T05:38:47", "url": "https://files.pythonhosted.org/packages/df/76/a99a6a1d0727aa96e645249e9f77a10574db662eadc67fa3d84181aa2203/confjson-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "152b2a8af953d511fd35af8bd14e2a95", "sha256": "71a132d991b6a174ef218c08772cab7d7511e691cd4411f1156f1d31f51c6c76" }, "downloads": -1, "filename": "confjson-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "152b2a8af953d511fd35af8bd14e2a95", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4594, "upload_time": "2018-10-22T18:17:51", "url": "https://files.pythonhosted.org/packages/9c/be/21899608d3c357074b5a63ddbc891b8d19e941b29690b54312e52efa078b/confjson-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce085a75c6a63ab3ce762df6967be20b", "sha256": "5a6b058c310a30b06c32e0c8d6b0f21be06a86dd7cce79ba9154e921d02b52cb" }, "downloads": -1, "filename": "confjson-1.1.0.tar.gz", "has_sig": false, "md5_digest": "ce085a75c6a63ab3ce762df6967be20b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3493, "upload_time": "2018-10-22T18:17:53", "url": "https://files.pythonhosted.org/packages/ce/18/b1c5458485839fab9fcef8d2937dfc331b91b70bcd9cea929d3541ca788f/confjson-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "625dd07b26525a6b887404c9283e7ff9", "sha256": "161f2ec728f3face98e9b58ce57d6c327926fe425bb8bf7ab1f0f1d732e969fc" }, "downloads": -1, "filename": "confjson-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "625dd07b26525a6b887404c9283e7ff9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4917, "upload_time": "2018-10-30T21:34:22", "url": "https://files.pythonhosted.org/packages/b6/5b/8cdb925ae94beb38155d0797f4563b4edbb2a57670a4bc7cc16d66236a0c/confjson-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ee33306ee5bc9249fb4e27fcb05912cd", "sha256": "b3ee2268c4953c47591febac5c0c9344ea7cf4defa913b35e6ff3913a58a56d7" }, "downloads": -1, "filename": "confjson-1.2.0.tar.gz", "has_sig": false, "md5_digest": "ee33306ee5bc9249fb4e27fcb05912cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3828, "upload_time": "2018-10-30T21:34:24", "url": "https://files.pythonhosted.org/packages/92/b3/8b668ed70075bf94034f1a505b81bac46da1ef6c794894cb5bfeaa7f1bec/confjson-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "8a9b606e46fa2927c73e0b73b7c8ee4f", "sha256": "86c9dbdc5ce0b13610cf0d59ef4040027d4c816fabfd4ca3d88a5dc5ed1e7f47" }, "downloads": -1, "filename": "confjson-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8a9b606e46fa2927c73e0b73b7c8ee4f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4970, "upload_time": "2018-11-08T19:51:54", "url": "https://files.pythonhosted.org/packages/fa/f0/06592fc5916e1c0892c5a1ccae1ba863e657ce6181610380bd3e7f475600/confjson-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e880fc3086de161868f5cc48b33ece9", "sha256": "a4659421cb70d5f671749f6ba1dcb9e71db61d4f7de6c2bc60c177eef224e287" }, "downloads": -1, "filename": "confjson-1.2.1.tar.gz", "has_sig": false, "md5_digest": "0e880fc3086de161868f5cc48b33ece9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3872, "upload_time": "2018-11-08T19:51:58", "url": "https://files.pythonhosted.org/packages/40/49/9cc8bfa1458ff6fe9d78ff04431bb9da625d2c0786aceb06d6de8c575ebd/confjson-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "eaf5eda24ad02ec90fe500489a52efa3", "sha256": "c203c848542ff0899b5b780efd232e221e4d09559aed193c15e6fb7871b13654" }, "downloads": -1, "filename": "confjson-1.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "eaf5eda24ad02ec90fe500489a52efa3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5141, "upload_time": "2018-11-09T19:39:56", "url": "https://files.pythonhosted.org/packages/d0/9d/3f020bb317dea5a627411e878209a9dc64b858fb6d6749b5815a057921bf/confjson-1.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5cad780b11d8fe31ee9c0400918c9d48", "sha256": "48001e50db90145cd65f8e67151a358d416a0aebf7dae05d996547e7a57a2d6a" }, "downloads": -1, "filename": "confjson-1.2.2.tar.gz", "has_sig": false, "md5_digest": "5cad780b11d8fe31ee9c0400918c9d48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4050, "upload_time": "2018-11-09T19:39:59", "url": "https://files.pythonhosted.org/packages/62/86/6866c6045457359c4df6244f4a6bef9d8c6840bd9688b6d77952eb556cca/confjson-1.2.2.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "7656be9300dfc4e14135116d68dab64a", "sha256": "55335ce7cf61bb2ae7b28a5d5c4d276b4ddb24fc3845a014a11f62b92f8de00e" }, "downloads": -1, "filename": "confjson-1.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7656be9300dfc4e14135116d68dab64a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 13252, "upload_time": "2018-11-15T19:45:32", "url": "https://files.pythonhosted.org/packages/9b/39/194dcc3157f9218b59cc3f7d48b7aacb1679cdaa210b1d01a579ad977ac9/confjson-1.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e9c039b898223a39705be63d25ae7ec", "sha256": "346a79bb2356716f0fab8e2615af8e678c6b98895bd5e9c2206ee064fa6ae833" }, "downloads": -1, "filename": "confjson-1.3.0.tar.gz", "has_sig": false, "md5_digest": "7e9c039b898223a39705be63d25ae7ec", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 9194, "upload_time": "2018-11-15T19:45:45", "url": "https://files.pythonhosted.org/packages/38/f6/328681e86b8a4dad302da4d05136c51abec91965915783e0f610c0a6c8d7/confjson-1.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7656be9300dfc4e14135116d68dab64a", "sha256": "55335ce7cf61bb2ae7b28a5d5c4d276b4ddb24fc3845a014a11f62b92f8de00e" }, "downloads": -1, "filename": "confjson-1.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7656be9300dfc4e14135116d68dab64a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 13252, "upload_time": "2018-11-15T19:45:32", "url": "https://files.pythonhosted.org/packages/9b/39/194dcc3157f9218b59cc3f7d48b7aacb1679cdaa210b1d01a579ad977ac9/confjson-1.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e9c039b898223a39705be63d25ae7ec", "sha256": "346a79bb2356716f0fab8e2615af8e678c6b98895bd5e9c2206ee064fa6ae833" }, "downloads": -1, "filename": "confjson-1.3.0.tar.gz", "has_sig": false, "md5_digest": "7e9c039b898223a39705be63d25ae7ec", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 9194, "upload_time": "2018-11-15T19:45:45", "url": "https://files.pythonhosted.org/packages/38/f6/328681e86b8a4dad302da4d05136c51abec91965915783e0f610c0a6c8d7/confjson-1.3.0.tar.gz" } ] }