{ "info": { "author": "Michael Loipfuehrer", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Modular-Config\n\n**modular-config** is a python package designed to make dynamic configuration inside a python \nproject as easy as possible. It follows a modular approach, meaning if you have a project\ncontaining several modules that each have parameters you'd like to be able to configure in\na central location, e.g. a config file while still being able to have the definition of those \nconfiguration parameters self contained in those individual modules then you've come to the\nright place. \n\n# Usage\n## Getting started\nFirst create a central config object that holds the whole configuration and synchronizes \nitself with the config file.\n```python\nfrom modular_conf import Config\n\nconfig = Config('config.json')\n```\nYou are now able to register a module with the configuration.\nCreate a list of config fields you want to have and register them under a module name.\n```python\nfrom modular_conf.fields import BoolField, StringField\n\nfields = [\n BoolField(name='field1', default=False),\n StringField(name='field2', default='Sample')\n]\n\nconfig.register_module('your_module_name', fields)\n```\nAfter registering the fields the config will synchronize with the config file. If the file is not present\nit will be created and if some field values are not yet contained in the config file it will be populated with\nthe given defaults.\nIn our case if no config file existed previously so a new one was created and looks as follows:\n```json\n{\n \"your_module_name\": {\n \"field1\": false,\n \"field2\": \"Sample\"\n }\n}\n```\nThe config can be accessed in your module and field values can be read and set via:\n```python\nconfig.get('your_module_name', 'field1')\nconfig.set('your_module_name', 'field2', 'new value')\n```\nSince each individual field was defined with a given type the config will automatically validate each field and raise\nan error if a type mismatch occurs. For example calling\n```python\nconfig.set('your_module_name', 'field2', False)\n``` \nWill raise an error as `field2` was defined as a `StringField`.\n\n## List of avaiable config field types\n- *IntField* - Simple integer\n- *StringField* - Simple string\n- *BoolField* - Simple boolean\n- *ChoiceField* - Field with a given set of possible choices (may be any type)\n- *ListField* - contains an arbitrary list\n- *TupleListField* - Contains a list of tuples. The tuples have a predefined length and have \nassociated names for each tuple element. E.g. a list of IP address, MAC address pairs. Tuple element names\nimprove readability and can be used in a frontend to render the config field.\n- *DictField* - contains an arbitrary dictionary\n\n# Installation\nSimply\n```bash\npip install modular-conf\n```\n\n# Contribution\nFeel free open pull requests. Contributions of any form are appreciated deeply!\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mikonse/modular_conf", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "modular-conf", "package_url": "https://pypi.org/project/modular-conf/", "platform": "", "project_url": "https://pypi.org/project/modular-conf/", "project_urls": { "Homepage": "http://github.com/mikonse/modular_conf" }, "release_url": "https://pypi.org/project/modular-conf/0.2/", "requires_dist": null, "requires_python": "", "summary": "A modular python configuration utility", "version": "0.2" }, "last_serial": 4988141, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "9e473b1f44990b1f2e75d5ecf20997b3", "sha256": "bacdd62592abc8c0a46ee295b680c1c118a9e6aa6d467f95a230046404aa76a4" }, "downloads": -1, "filename": "modular_conf-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9e473b1f44990b1f2e75d5ecf20997b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6306, "upload_time": "2019-03-26T15:18:55", "url": "https://files.pythonhosted.org/packages/d6/eb/9e0f451053020e374409a8f6016fdd7c2e9de544a24799ebca1ca8f328ee/modular_conf-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1adbcacdccb125e6a8fed8b734de4ab8", "sha256": "f89bbb0e43a9e93e05cca80ebf6124bef7f0a58838ba97591b2b766ac7cd8265" }, "downloads": -1, "filename": "modular-conf-0.2.tar.gz", "has_sig": false, "md5_digest": "1adbcacdccb125e6a8fed8b734de4ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5625, "upload_time": "2019-03-26T15:18:56", "url": "https://files.pythonhosted.org/packages/38/86/92bf1248df63d5917fba4c2f3823a3c6bc493b70f34123078ba505dea498/modular-conf-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9e473b1f44990b1f2e75d5ecf20997b3", "sha256": "bacdd62592abc8c0a46ee295b680c1c118a9e6aa6d467f95a230046404aa76a4" }, "downloads": -1, "filename": "modular_conf-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9e473b1f44990b1f2e75d5ecf20997b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6306, "upload_time": "2019-03-26T15:18:55", "url": "https://files.pythonhosted.org/packages/d6/eb/9e0f451053020e374409a8f6016fdd7c2e9de544a24799ebca1ca8f328ee/modular_conf-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1adbcacdccb125e6a8fed8b734de4ab8", "sha256": "f89bbb0e43a9e93e05cca80ebf6124bef7f0a58838ba97591b2b766ac7cd8265" }, "downloads": -1, "filename": "modular-conf-0.2.tar.gz", "has_sig": false, "md5_digest": "1adbcacdccb125e6a8fed8b734de4ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5625, "upload_time": "2019-03-26T15:18:56", "url": "https://files.pythonhosted.org/packages/38/86/92bf1248df63d5917fba4c2f3823a3c6bc493b70f34123078ba505dea498/modular-conf-0.2.tar.gz" } ] }