{ "info": { "author": "Damien Garros", "author_email": "dgarros@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "[![Build Status](https://travis-ci.org/dgarros/defconf.svg?branch=master)](https://travis-ci.org/dgarros/defconf)\r\n\r\n# Defconf\r\nPython Library/tool to easily define and validate the format and content of a configuration file\r\n\r\nTo build a robust application, it takes a lot of effort to properly check and\r\nvalidate everything that can goes wrong within an input file filled by users:\r\n- Wrong option name : login VS username,\r\n- Wrong type : string instead of integer,\r\n- Mandatory information missing\r\n- Value not conform (ip address not valid etc ..)\r\n\r\nAll this complexity is often not completely managed by the application has it\r\nrequire a LOT of work:\r\nDefconf is here to help, it will:\r\n+ Validate the format of the configuration file (list, dict, string)\r\n+ Validate all names and track unsupported options\r\n+ Validate content type (integer, string, bool, list, dict)\r\n+ Validate the value with REGEX or pre-define list\r\n+ Populate default value if information is missing\r\n\r\n## How does it work\r\nCreate a definition file to define how your configuration should look like\r\n\r\nFor this simple configuration file\r\n```yaml\r\nhttp_server: [ 192.168.0.1, 192.168.0.2 ]\r\npassword: pwd!!\r\nport: 4444\r\n```\r\n\r\nA corresponding defconf file will looks like this\r\n```yaml\r\nvalidate:\r\n main:\r\n http_server: { type: list, validate: ip_addr, mandatory: 1 }\r\n password: { type: string, validate: valid_password, mandatory: 1 }\r\n port: { type: integer, values: [4444, 2580], default: 4444 }\r\n\r\nregex:\r\n ip_addr: ^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$\r\n valid_password: ^[A-Za-z0-9\\!]+$\r\n```\r\nFor each option on the configuration file, we can define:\r\n- type => [string, integer, bool, dict, list]\r\n- mandatory => [0, 1]\r\n- values => List of supported values (only for integer, string and list type)\r\n- validate => Advance validation with Regex or with another validate block (nested dict)\r\n- default => Default value if option is not defined\r\n\r\nDetail example available here :\r\n- [Configuration file - myconfig.yml]( https://github.com/dgarros/defconf/blob/master/myconfig.yml)\r\n- [Definition file - myconfig.def.yml]( https://github.com/dgarros/defconf/blob/master/myconfig.def.yml)\r\n\r\n#### From CLI (within project folder)\r\n python defconf.py myconfig.yml myconfig.def.yml\r\n\r\n#### From python\r\n```python\r\nimport defconf\r\n\r\ndefinition = yaml.load( open('myconfig.def.yml') )\r\nconfig = yaml.load( open('myconfig.yml') )\r\ndefconf.validate_config( config, definition, 'myconfig' )\r\n```\r\n\r\n## Installation\r\n git clone https://github.com/dgarros/defconf\r\n\r\n## Enhancements list\r\n- Support JSON file in addition to YAML\r\n- Improve exception handling to catch as many issue as possible in one shot\r\n- Create example config file from Definition file\r\n- Create definition file for definition files :)\r\n- Create a module and publish\r\n\r\n## Support\r\nBug and issues can be open on Github [https://github.com/dgarros/defconf/issues]\r\n\r\n## How to contribute\r\n- Use it and share your config/def files\r\n- Report issue\r\n- Add unit tests\r\n- Improve documentation\r\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dgarros/defconf", "keywords": "validationtool definition configuration development", "license": "Apache", "maintainer": null, "maintainer_email": null, "name": "defconf", "package_url": "https://pypi.org/project/defconf/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/defconf/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dgarros/defconf" }, "release_url": "https://pypi.org/project/defconf/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Python Library/tool to easily define and validate the format and content of a configuration file", "version": "0.2.0" }, "last_serial": 1707270, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "76564ee9111966d7bf895b14579dbe93", "sha256": "ba95391f3db6c41ead8f8e3cd023834eafac6c5e818449976f689377a07922b5" }, "downloads": -1, "filename": "defconf-0.1.0.tar.gz", "has_sig": false, "md5_digest": "76564ee9111966d7bf895b14579dbe93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3324, "upload_time": "2015-09-03T18:02:08", "url": "https://files.pythonhosted.org/packages/e0/51/f14a93f05f604848462b053f0183ba8ed2fdf94a4fe4895aa89657707b02/defconf-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "0e4c0f41bcc9a3db1f9a99bedd3f7f28", "sha256": "bf9d63bc737812ce6ddb2753231f9e3768697ed7dfddd8504c55a778b6ee8341" }, "downloads": -1, "filename": "defconf-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0e4c0f41bcc9a3db1f9a99bedd3f7f28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3333, "upload_time": "2015-09-03T21:54:49", "url": "https://files.pythonhosted.org/packages/2b/4a/6d0bc83b0ae8788e0626716167d6421c82c2e0f2cd2174733eeeb987aed7/defconf-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "35560006bd61c0919412a30216db508b", "sha256": "38ca3780b0d5a0ceafa7abf4dec14ce407c3b8465dca790fa0c2c1a3cf5ecb69" }, "downloads": -1, "filename": "defconf-0.2.0.tar.gz", "has_sig": false, "md5_digest": "35560006bd61c0919412a30216db508b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6646, "upload_time": "2015-09-03T23:58:04", "url": "https://files.pythonhosted.org/packages/08/e2/3f4736394a60bf3803a4268d4b4d0f992aca85f5c652bde5668cf6248815/defconf-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "35560006bd61c0919412a30216db508b", "sha256": "38ca3780b0d5a0ceafa7abf4dec14ce407c3b8465dca790fa0c2c1a3cf5ecb69" }, "downloads": -1, "filename": "defconf-0.2.0.tar.gz", "has_sig": false, "md5_digest": "35560006bd61c0919412a30216db508b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6646, "upload_time": "2015-09-03T23:58:04", "url": "https://files.pythonhosted.org/packages/08/e2/3f4736394a60bf3803a4268d4b4d0f992aca85f5c652bde5668cf6248815/defconf-0.2.0.tar.gz" } ] }