{ "info": { "author": "RobertoPrevato", "author_email": "roberto.prevato@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "[![Build status](https://robertoprevato.visualstudio.com/roconfiguration/_apis/build/status/roconfiguration-CI)](https://robertoprevato.visualstudio.com/roconfiguration/_build/latest?definitionId=10) [![pypi](https://robertoprevato.vsrm.visualstudio.com/_apis/public/Release/badge/4e64eee9-f7ef-42ea-95db-bccc8244d41d/1/2)](https://pypi.org/project/roconfiguration/) [![Test coverage](https://img.shields.io/azure-devops/coverage/robertoprevato/roconfiguration/10.svg)](https://robertoprevato.visualstudio.com/roconfiguration/_build?definitionId=10)\n\n# Python configuration utilities\nImplementation of key-value pair based configuration for Python applications.\n\n**Features:**\n* support for most common sources of application settings\n* support for overriding settings in sequence\n* support for nested structures and lists, using attribute notation\n* strategy to use environment specific settings\n\nThis library is freely inspired by .NET Core `Microsoft.Extensions.Configuration` namespace and its pleasant design (_ref. [MSDN documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.1), [Microsoft Extensions Configuration Deep Dive](https://www.paraesthesia.com/archive/2018/06/20/microsoft-extensions-configuration-deep-dive/)_).\n\nThe main class is influenced by Luciano Ramalho's example of \nJSON structure explorer using attribute notation, in his book [Fluent Python](http://shop.oreilly.com/product/0636920032519.do).\n\n## Supported sources:\n* **yaml** files\n* **json** files\n* **ini** files\n* environmental variables\n* dictionaries\n* keys and values\n\n## Installation\n```bash\npip install roconfiguration\n```\n\n# Examples\n\n### YAML file and environmental variables\nIn this example, configuration will be comprised of anything inside a file `settings.yaml` and environmental variables. Settings are applied in order, so environmental variables with matching name override values from the `yaml` file.\n\n\n```python\nfrom roconfiguration import Configuration\n\nconfig = Configuration()\n\nconfig.add_yaml_file('settings.yaml')\n\nconfig.add_environmental_variables()\n```\n\n### YAML file, optional file by environment\nIn this example, if an environmental variable with name `APP_ENVIRONMENT` and value `dev` exists, and a configuration file with name `settings.dev.yaml` is present, it is read to override values configured in `settings.yaml` file. \n```python\nimport os\nfrom roconfiguration import Configuration\n\nenvironment_name = os.environ['APP_ENVIRONMENT']\n\nconfig = Configuration()\n\nconfig.add_yaml_file('settings.yaml')\nconfig.add_yaml_file(f'settings.{environment_name}.yaml', optional=True)\n\nconfig.add_environmental_variables()\n```\n\n### Filtering environmental variables by prefix\n```python\nimport os\nfrom roconfiguration import Configuration\n\nconfig = Configuration()\n\n# will read only environmental variables\n# starting with 'APP_', case insensitively\nconfig.add_environmental_variables('APP_')\n```\n\n### Ini files\nIni files are parsed using the built-in `configparser` module, therefore support `[DEFAULT]` section; all values are kept as strings.\n```python\nfrom roconfiguration import Configuration\n\nconfig = Configuration()\n\nconfig.add_ini_file('settings.ini')\n```\n\n### JSON files\nJSON files are parsed using the built-in `json` module.\n```python\nfrom roconfiguration import Configuration\n\nconfig = Configuration()\n\nconfig.add_json_file('settings.json')\n```\n\n### Dictionaries\n```python\nfrom roconfiguration import Configuration\n\nconfig = Configuration({'host': 'localhost', 'port': 8080})\n\nconfig.add_map({\n 'hello': 'world',\n 'example': [{\n 'id': 1\n }, {\n 'id': 2\n }]\n})\n\nassert config.host == 'localhost'\nassert config.port == 8080\nassert config.hello == 'world'\nassert config.example[0].id == 1\nassert config.example[1].id == 2\n```\n\n### Keys and values\n```python\nfrom roconfiguration import Configuration\n\nconfig = Configuration({'host': 'localhost', 'port': 8080})\n\nconfig.add_value('port', 44555)\n\nassert config.host == 'localhost'\nassert config.port == 44555\n```\n\n### Overriding nested values\n```python\nconfig = Configuration({'a': {\n 'b': 1,\n 'c': 2,\n 'd': {\n 'e': 3,\n 'f': 4\n }\n}})\n\nassert config.a.b == 1\nassert config.a.d.e == 3\nassert config.a.d.f == 4\n\nconfig.add_value('a:d:e', 5)\n\nassert config.a.d.e == 5\nassert config.a.d.f == 4\n```\n\n### Overriding nested values using env variables\n```python\nconfig = Configuration({'a': {\n 'b': 1,\n 'c': 2,\n 'd': {\n 'e': 3,\n 'f': 4\n }\n}})\n\nassert config.a.b == 1\nassert config.a.d.e == 3\nassert config.a.d.f == 4\n\n# NB: if an env variable such as:\n# a:d:e=5\n# or...\n# a__d__e=5\n#\n# is defined, it overrides the value from the dictionary\n\nconfig.add_environmental_variables()\n\nassert config.a.d.e == 5\n```\n\n### Overriding values in list items using env variables\n```python\nconfig = Configuration({'b2c': [\n {'tenant': '1'},\n {'tenant': '2'},\n {'tenant': '3'}\n]})\n\nconfig.add_value('b2c:1:tenant', '4')\n\nassert config.b2c[0].tenant == '1'\nassert config.b2c[1].tenant == '4'\nassert config.b2c[2].tenant == '3'\n```\n\n---\n\n# Develop and run tests locally\n```bash\npip install -r dev_requirements.txt\n\n# run tests using automatic discovery:\npytest\n```\n\n\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/RobertoPrevato/roconfiguration", "keywords": "configuration core yaml ini json environment", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "roconfiguration", "package_url": "https://pypi.org/project/roconfiguration/", "platform": "", "project_url": "https://pypi.org/project/roconfiguration/", "project_urls": { "Homepage": "https://github.com/RobertoPrevato/roconfiguration" }, "release_url": "https://pypi.org/project/roconfiguration/1.0.6/", "requires_dist": [ "PyYAML" ], "requires_python": "", "summary": "Implementation of key-value pair based configuration for Python applications.", "version": "1.0.6" }, "last_serial": 5458840, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9d4883aa355c1e6d67e6102f4ac48ce5", "sha256": "0e85249086e665b3506c310866c64207be83b47dae1c69772c659a77ad8c7fcb" }, "downloads": -1, "filename": "roconfiguration-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9d4883aa355c1e6d67e6102f4ac48ce5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5557, "upload_time": "2018-09-14T20:27:36", "url": "https://files.pythonhosted.org/packages/0d/a6/7a7ff39ce229ae19dd5147edc90f837a80956d06299e932e9571acbec72d/roconfiguration-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8f3fb17f11760bce6db499b7102e1255", "sha256": "948a8c823add3768aba2b7d4a88f3608644fe26dc3d7183bad4c08ee6f0aa26d" }, "downloads": -1, "filename": "roconfiguration-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8f3fb17f11760bce6db499b7102e1255", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5551, "upload_time": "2018-09-14T20:31:40", "url": "https://files.pythonhosted.org/packages/ed/5f/022669c46a39f48699f1b704c9230ba08b51a374e4921e3d156f64bc45ff/roconfiguration-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "083f6698a7d880965a5b215ddcb03f2c", "sha256": "1adabe38ae4eeade8624fc7fe6019603a4242479f094b2b497ee46991eae1ddf" }, "downloads": -1, "filename": "roconfiguration-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "083f6698a7d880965a5b215ddcb03f2c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4816, "upload_time": "2018-09-16T18:36:24", "url": "https://files.pythonhosted.org/packages/06/bd/4aed10bae13e7cd11785a8d68a3afb47512ab93e66765daba9a57a0a56c7/roconfiguration-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "645735bc78f6ef8836033028955be295", "sha256": "6fe9e7a5a1e6a0b8322af92518b40c2a0339af93715da631ccd0330bb3f2ea6e" }, "downloads": -1, "filename": "roconfiguration-1.0.2.tar.gz", "has_sig": false, "md5_digest": "645735bc78f6ef8836033028955be295", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5638, "upload_time": "2018-09-16T18:36:26", "url": "https://files.pythonhosted.org/packages/73/59/3f7a46da40366b638f439a16ac1f88ac60c490a2ad8dfbb3abb67270a826/roconfiguration-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "73f20918f062976c8c70d5817b3afff3", "sha256": "3bee57408e5d904f35d400b8e05e1ee4251b7ab0ff10aaabb86073e78fa54e56" }, "downloads": -1, "filename": "roconfiguration-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "73f20918f062976c8c70d5817b3afff3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5760, "upload_time": "2019-05-17T17:50:41", "url": "https://files.pythonhosted.org/packages/1b/d9/1fe8f2c18dd2d0d96db7333c8ea0274241d0adc3a9be14e6ad4de27895b4/roconfiguration-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0b1e0df1c0adca9f63a41563bb7d411b", "sha256": "071d096021c76aee4fcf897f0987cf7bec694b032917a5a04bacffbb3500c85d" }, "downloads": -1, "filename": "roconfiguration-1.0.3.tar.gz", "has_sig": false, "md5_digest": "0b1e0df1c0adca9f63a41563bb7d411b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5706, "upload_time": "2019-05-17T17:50:42", "url": "https://files.pythonhosted.org/packages/1d/38/8508bda1b82be42d0cc2e87c422e5b7ba1c4a2a9d1921e74a32b49ef3f42/roconfiguration-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "25a65d261b7d9acc197ca55b2fd6c997", "sha256": "803b11675327f4cf7630176f951a957e72c377ea2dc70128ad54302bf1b7c971" }, "downloads": -1, "filename": "roconfiguration-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "25a65d261b7d9acc197ca55b2fd6c997", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5959, "upload_time": "2019-05-21T21:58:49", "url": "https://files.pythonhosted.org/packages/2b/f8/0b3f9de82151ce1669921458ffc0dfeaaca5a95699379b32d93ac1dd8839/roconfiguration-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3732786fd6e1607f169be43513d76c90", "sha256": "5f509629ec6aa1d0437cd4afa5c5135d2451ee55503c55c0fc875e6de2ad407d" }, "downloads": -1, "filename": "roconfiguration-1.0.4.tar.gz", "has_sig": false, "md5_digest": "3732786fd6e1607f169be43513d76c90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5921, "upload_time": "2019-05-21T21:58:51", "url": "https://files.pythonhosted.org/packages/84/17/7cb0a66fd5069391a9bfebaccb5a4b46f6e4c946bdbe7d25641ccb42b959/roconfiguration-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "3378973cd1ae95af00f2b2441bc9a906", "sha256": "c75ef9114a6b4afafa53b5f8d32408b0550572a392c51ba4a65c1488cb2b599c" }, "downloads": -1, "filename": "roconfiguration-1.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "3378973cd1ae95af00f2b2441bc9a906", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6057, "upload_time": "2019-06-27T20:20:38", "url": "https://files.pythonhosted.org/packages/e6/fb/74f8b7346df72a6712c728271bd2a278b8c1c1559f309079fe5217f3c9d3/roconfiguration-1.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3fd0d7127edc7aa60decb45b3c02c11", "sha256": "5b570c1c6fd2802d5045fac6e4ba3984d1e8326e4fe1c8395ac5a1cbbc0ff327" }, "downloads": -1, "filename": "roconfiguration-1.0.5.tar.gz", "has_sig": false, "md5_digest": "f3fd0d7127edc7aa60decb45b3c02c11", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6021, "upload_time": "2019-06-27T20:20:40", "url": "https://files.pythonhosted.org/packages/12/30/a8518830515c02283d4607877034900d02f03be6d4fb9c93aac4ad465301/roconfiguration-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "c34358cc4f0c8b67966c3935c62fe6b0", "sha256": "a4cb1c61ee2bcf6ffdab0d9d82be7f3f62eb03bcbac11f983b7d23fee423a9a7" }, "downloads": -1, "filename": "roconfiguration-1.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "c34358cc4f0c8b67966c3935c62fe6b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6074, "upload_time": "2019-06-27T20:29:27", "url": "https://files.pythonhosted.org/packages/e7/19/ec2e087fe3ae6045545a4af5e61673bf84ac244e440ed7387d0e86c35416/roconfiguration-1.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "710f494aab68142b14ca202949f54e84", "sha256": "3350da617a0b6c937e040cff66713416835e48b91491bd5516b4044c5a825a38" }, "downloads": -1, "filename": "roconfiguration-1.0.6.tar.gz", "has_sig": false, "md5_digest": "710f494aab68142b14ca202949f54e84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6039, "upload_time": "2019-06-27T20:29:28", "url": "https://files.pythonhosted.org/packages/1f/4f/c23c0dee790a7c7baa6e5a29b050b1fad44c42bd438a1dd493952eeccc75/roconfiguration-1.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c34358cc4f0c8b67966c3935c62fe6b0", "sha256": "a4cb1c61ee2bcf6ffdab0d9d82be7f3f62eb03bcbac11f983b7d23fee423a9a7" }, "downloads": -1, "filename": "roconfiguration-1.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "c34358cc4f0c8b67966c3935c62fe6b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6074, "upload_time": "2019-06-27T20:29:27", "url": "https://files.pythonhosted.org/packages/e7/19/ec2e087fe3ae6045545a4af5e61673bf84ac244e440ed7387d0e86c35416/roconfiguration-1.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "710f494aab68142b14ca202949f54e84", "sha256": "3350da617a0b6c937e040cff66713416835e48b91491bd5516b4044c5a825a38" }, "downloads": -1, "filename": "roconfiguration-1.0.6.tar.gz", "has_sig": false, "md5_digest": "710f494aab68142b14ca202949f54e84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6039, "upload_time": "2019-06-27T20:29:28", "url": "https://files.pythonhosted.org/packages/1f/4f/c23c0dee790a7c7baa6e5a29b050b1fad44c42bd438a1dd493952eeccc75/roconfiguration-1.0.6.tar.gz" } ] }