{ "info": { "author": "Max von Tettenborn", "author_email": "max@vtettenborn.net", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# gconf\n\nManaging a config globally throughout a Python application\n\n## Overview\n\nWith gconf, yaml configuration files can be loaded on module-scope\nsuch that its values can be accessed from anywhere in a running application.\n\n## Usage\n\n### Loading yaml files\n\nOne or more yaml configuration files are loaded globally from path-like objects,\nusually in a program's main function.\nThe resulting configuration is an overlay of all loaded configurations\nwith those that were loaded later taking precedence.\n\nLoading a single config file:\n```python\ngconf.load('conf.yml')\n```\n\nLoading multiple config files at once:\n```python\ngconf.load('conf1.yml', 'conf2.yml')\n```\n\nLoading multiple config files one after the other:\n```python\ngconf.load('conf1.yml')\ngconf.load('conf2.yml')\n```\n\nThe two examples above produce an identical result.\nIn both cases `config2` takes precedence over `config1` and overrides its values.\n\nEach invocation of `load` returns a list of all paths that have actually been loaded.\n\nLoading the first config from a list of paths:\n```python\ngconf.load_first('conf1.yml', 'conf2.yml')\n```\n\nIf `conf1.yml` exists, it is loaded and `conf2.yml` is ignored.\nif `conf1.yml` does not exist, `conf2.yml` is loaded.\n\n`load_first` returns the path that has actually been loaded.\n\nAll loading functions raise a `FileNotFoundError` if no file is found.\nThis can be prevented by setting the keyword-argument `required=False`.\n\n\n### Manually adding values\n\nA dict can be added to the config from within the application.\nThis is equivalent to loading a config file with the same content\nand overrides values if they are already present or adds them if not.\n\n```python\ngconf.add({'parent': {'child': 'new child'}})\n```\n\nWarning: using this functionality, it is possible to the gconf module as a store for global variables.\nGlobal variables are a code smell and should not be used!\nPlease use the `gconf.add()` function only if you know exactly what you are doing.\n\n\n### Accessing config values\n\nThere are several ways of addressing the values that are stored in the config,\nall of them using the module-level `get` method.\n\nDot-notation\n```python\ngconf.get('parent.child.some value')\n```\n\nString arguments\n```python\ngconf.get('parent', 'child', 'some value')\n```\n\nA mix of both\n```python\ngconf.get('parent.child', 'some value')\n```\n\nTop-level item as dictionary\n```python\ngconf.get()['parent']['child']['some value']\n```\n\nSome intermediate item as dictionary\n```python\ngconf.get('parent')['child']['some value']\n```\n\nTo access list items, simply use their index in the path\n```python\ngconf.get('list.3')\n```\n\n#### Default value\n\nThe `get` method accepts a `default` argument, which is returned\nif the specified item does not exist:\n```python\ngconf.get('non-existing', default=default_value)\n```\n\n### Errors\n\nIf an attempt is made at loading non-existing files and `required=True` (the default), an `FileNotFoundError` is raised.\n\nIf no `default` is provided, an attempt to access a non-existing item raises a `KeyError`.\n\n### Temporary override\n\nParts of the config can be temporarily overridden through a context manager.\nPass it a dictionary that overlays the existing one:\n```python\nwith gconf.override_conf({'parent': {'child': 'override_value'}}):\n gconf.get('parent.child') # => 'override_value'\ngconf.get('parent.child') # => 'original_value'\n```\n\nTo temporarily remove parts of the config the `DELETED` constant can be used:\n```python\nwith gconf.override_conf({'parent': {'child': gconf.DELETED}}):\n gconf.get('parent.child') # => KeyError\ngconf.get('parent.child') # => 'original_value'\n```\n\n### Resetting\n\nThe global gconf dict can be completely reset.\n\n```python\ngconf.reset()\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/max-tet/gconf", "keywords": "", "license": "LICENSE", "maintainer": "", "maintainer_email": "", "name": "gconf", "package_url": "https://pypi.org/project/gconf/", "platform": "", "project_url": "https://pypi.org/project/gconf/", "project_urls": { "Homepage": "https://gitlab.com/max-tet/gconf" }, "release_url": "https://pypi.org/project/gconf/0.6.2/", "requires_dist": null, "requires_python": "", "summary": "Managing a config globally throughout a Python application", "version": "0.6.2" }, "last_serial": 5196223, "releases": { "0.5.2": [ { "comment_text": "", "digests": { "md5": "6acbb0bef77e521412f44fb26d9ef71c", "sha256": "a2f24bad951cfdb971e20c8a516b066f71dd04c88f59c17f2c0713bd56e5ea13" }, "downloads": -1, "filename": "gconf-0.5.2.tar.gz", "has_sig": false, "md5_digest": "6acbb0bef77e521412f44fb26d9ef71c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3970, "upload_time": "2019-03-13T17:16:39", "url": "https://files.pythonhosted.org/packages/09/da/893e29c361d46d49d50d0083031faada0a0021aa1155e23dc5d4e6ff5c5a/gconf-0.5.2.tar.gz" } ], "0.5.4": [ { "comment_text": "", "digests": { "md5": "f1a13c90657742db8cc1992265fffef4", "sha256": "2f2da4c8d759789812f8bdfc4f708ab92dc23a2628cda412c387c41d71d8a7d4" }, "downloads": -1, "filename": "gconf-0.5.4.tar.gz", "has_sig": false, "md5_digest": "f1a13c90657742db8cc1992265fffef4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4601, "upload_time": "2019-03-14T16:50:50", "url": "https://files.pythonhosted.org/packages/2f/69/052ba4e25770bbe2ea28ee7b20ed87042f1153183dbb7d383c095df6a7b3/gconf-0.5.4.tar.gz" } ], "0.5.5": [ { "comment_text": "", "digests": { "md5": "4018ce6d8a5cc275eae3d49c79f6d655", "sha256": "844cb3d48d6151eb8b1f6622bc432e159c7c9ccb577e6aa2930d44c233c0c008" }, "downloads": -1, "filename": "gconf-0.5.5.tar.gz", "has_sig": false, "md5_digest": "4018ce6d8a5cc275eae3d49c79f6d655", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4604, "upload_time": "2019-03-23T23:03:27", "url": "https://files.pythonhosted.org/packages/cb/ac/05bcee409a74fa7ea87b8e4790ba01e3eb944276fa37426b7e2672f6b1ae/gconf-0.5.5.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "fd26f3392ee6f83ab9c3966022b1a0b0", "sha256": "a88edb914994493d88d269470c3af80c8268d75ba9868956b465f9c2e898a88f" }, "downloads": -1, "filename": "gconf-0.6.0.tar.gz", "has_sig": false, "md5_digest": "fd26f3392ee6f83ab9c3966022b1a0b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4659, "upload_time": "2019-04-11T09:17:47", "url": "https://files.pythonhosted.org/packages/9b/21/52e2e16b15657b029d19d5ccdfafd1601408f1856137b9974272f4dc0247/gconf-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "26077a8d70c3f69705cc5de1a0de81f0", "sha256": "5951a3568f958482fe1b112d5cd47e2fb8f45d6017cdb5177ec87e57d6eb81e7" }, "downloads": -1, "filename": "gconf-0.6.1.tar.gz", "has_sig": false, "md5_digest": "26077a8d70c3f69705cc5de1a0de81f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4659, "upload_time": "2019-04-13T18:37:11", "url": "https://files.pythonhosted.org/packages/29/69/50ddfa94d69e5e18e758d44bc1b2e2712d5626cc94685510d4e63c58e85e/gconf-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "25b4e4b0227863e2d751e9f9202293da", "sha256": "3fb7974113209dbdc8200745df36134e9557746862239fd75230d2b02fda865b" }, "downloads": -1, "filename": "gconf-0.6.2.tar.gz", "has_sig": false, "md5_digest": "25b4e4b0227863e2d751e9f9202293da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4719, "upload_time": "2019-04-27T09:00:34", "url": "https://files.pythonhosted.org/packages/48/b4/a8064dec28979a3f2fc0cfa454882aeeb53dcbcdbe6e49351c6a6e255e3f/gconf-0.6.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "25b4e4b0227863e2d751e9f9202293da", "sha256": "3fb7974113209dbdc8200745df36134e9557746862239fd75230d2b02fda865b" }, "downloads": -1, "filename": "gconf-0.6.2.tar.gz", "has_sig": false, "md5_digest": "25b4e4b0227863e2d751e9f9202293da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4719, "upload_time": "2019-04-27T09:00:34", "url": "https://files.pythonhosted.org/packages/48/b4/a8064dec28979a3f2fc0cfa454882aeeb53dcbcdbe6e49351c6a6e255e3f/gconf-0.6.2.tar.gz" } ] }