{ "info": { "author": "Shahar Evron", "author_email": "shahar@shoppimon.com", "bugtrack_url": null, "classifiers": [], "description": "Figcan - Minimalistic Configuration Handling Library\n==================================================== \n*Figcan* is a minimalistic configuration handling library for Python.\n\nIt is designed to help you manage runtime configuration coming from different \nsources, without making any assumptions about configuration file formats and \nlocations, and while staying super simple to use for common use cases.\n\nFigcan has no runtime dependencies other than Python versions 2.7 or 3.4 and \nup. \n\n[![Build Status](https://travis-ci.org/shoppimon/figcan.svg?branch=master)](https://travis-ci.org/shoppimon/figcan)\n\nFigcan's Philosophy\n-------------------\n*Figcan*'s design is based on a few basic assumptions:\n\n* Configuration is important in any but the most simple projects\n* Configuration can easily be described as a set of nested key-value pairs \n where values can have a few native scalar types (booleans, strings, numbers) \n or container types (lists, mappings)\n* Python dictionaries are *almost* perfect for configuration. *Almost*.\n* Configuration keys can be known in advance. The structure of your expected\n configuration is almost always known to your project's code and thus can be \n described in advance. \n* Configuration can come from multiple sources: in-code defaults, multiple \n configuration files, environment variables, command line arguments, \n database-persisted key-value pairs etc. \n* But realistically, objects read from these sources are not that different \n from each other: they can almost always be represented as Python object \n attributes or dictionaries\n* There is already a Python module in out there that handles reading values \n from these sources and converting them to some kind of native dictionary or \n object \n\nWith those in mind, here is what *Figcan* will do:\n\n* Provide a dictionary-like object containing configuration\n* This object is created from a dictionary specifying your default \n configuration\n* Additional configuration values (in the form of Python dictionaries or \n objects) can be \"layered\" on top of this default configuration to override \n values\n\nAnd here is what *Figcan* will not do for you in one line - but supports doing\nvery easily with just a few lines of custom code you will need to write:\n\n* Read and parse files in specific formats (`INI`, `JSON`, `YAML` etc.)\n* Look for configuration files in specific places, based on OS or environment\n* Read values from a specific command line argument parsers (`argparse`, \n `optparse`, `click` etc.) \n* Manage saving configuration to files or anywhere else\n* Provide any API to accessing configuration beyond what the Python `dict` \n interface provides (which, if you ask us, should be enough for everybody)\n\nWe plan to provide some documentation and examples on how to get these done\nwith *Figcan*. \n\nGetting Started\n---------------\n\n### Installation\nIt is recommended to add *Figcan* to your project using `pip`:\n\n pip install figcan\n\nYou should also be able to install directly from the source tree pulled from \ngit:\n\n `TBD`\n\n### Using in your project\nTypically, *Figcan* is used by reading configuration from all sources at the \nbeginning of your program (e.g. in your `main`), and making the configuration \nobject available to all other parts of the program as needed. \n\nHere is a very basic (but not unrealistic) usage example:\n\n```python\nimport os\nfrom figcan import Configuration\nfrom my_project.config import default_config # A dictionary defining default configuration values\n\ndef main():\n config = Configuration(default_config)\n\n # Apply configuration overrides from environment variables\n config.apply_flat(os.environ, prefix='MYPROJECT')\n\n # Do something with the configuration:\n db_engine = sqlalchemy.create_engine(config['db']['url'])\n```\n\n#### Applying configuration from YAML or JSON files:\nIf your configuration is saved in a file format that can be parsed into a \nPython `dict`, you can easily get *Figcan* to work with it. For example: \n\n```python\nimport yaml\nfrom figcan import Configuration\nfrom my_project.config import default_config # A dictionary defining default configuration values\n\ndef main(config_file_path):\n config = Configuration(default_config)\n\n with open(config_file_path) as f:\n config.apply(yaml.safe_load(f))\n\n # Do something with the configuration:\n db_engine = sqlalchemy.create_engine(config['db']['url'])\n```\n\nNote that `Configuration.apply` will raise an exception if it encounters a\nconfiguration key that is not present in your `default_config`. This can be\nchanged like so:\n\n```python\nconfig.apply(yaml.safe_load(f), raise_on_unknown_key=False)\n```\n\nIf you want to allow merging new configuration keys into a configuration \nsection, you will need to define that section as `Extensible` in the base\nconfiguration:\n\n```python\nfrom figcan import Configuration, Extensible\n\ndefault_config = dict({ # Base configuration keys are known ahead and static \n 'bind_port': 5656,\n 'db': { # Database settings keys are known ahead and static\n 'hostname': 'db.local',\n 'username': 'foobar',\n 'password': 'blahblah'\n } ,\n 'logging': Extensible({ # But logging settings are flexible, and new handlers / loggers can be defined\n 'handlers': {\n 'handler_1': '...'\n }\n })\n})\n\nconfig = Configuration(default_config)\n\n# This will not raise an exception and 'handler_2' config will be available in `config`:\nconfig.apply({\"logging\": {\"handlers\": {\"handler_2\": \"... more config ...\"}}})\n```\n\n#### Applying configuration from environment variables:\n\n#### Applying configuration from command line arguments:\n\n## Some Alternatives to Consider\nThere are many configuration handling libraries for Python. Some may be more \nsuitable for you than *Figcan* (some we have tried before deciding to write \n*Figcan*):\n\n* \n* \n* \n\n## TODO / Planned Features\n\n### Schema based type coercion and validation of configuration values\nthe idea here is that the initial `default_config` dict will also contain some\ntype annotations in some form. These will be used to coerce override values \n(e.g. when coming as strings from environment variables) and to do some \nvalidation when configuration is applied. \n\n### Allow defining \"flexible\" vs \"non-flexible\" configuration mapping\nFor example, a `logging` section used for `logging.config.dictConfig` typically\nneeds to have a flexible structure. However, making everything flexible can \nlead to typos etc. not being detected.\n\n## Credits\nFigcan was created by the [Shoppimon](https://www.shoppimon.com) team and is in\nuse by Shoppimon in highly used, critical production code. \n\n## License\n\u00a9 2018 Shoppimon LTD, all rights reserved\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\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/shoppimon/figcan", "keywords": "configuration config management yaml json ini arguments simple", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "figcan", "package_url": "https://pypi.org/project/figcan/", "platform": "", "project_url": "https://pypi.org/project/figcan/", "project_urls": { "Homepage": "https://github.com/shoppimon/figcan" }, "release_url": "https://pypi.org/project/figcan/0.0.4/", "requires_dist": [ "typing; python_version < \"3.0\"" ], "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "summary": "Figcan - minimalistic configuration handling library for Python", "version": "0.0.4" }, "last_serial": 4440055, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "4265807aefc49a2c7b4ff633a56934e4", "sha256": "969fb9578215c1bde7da15dacf6dce5637cc68eba8a2a8445b235125f9ca757e" }, "downloads": -1, "filename": "figcan-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4265807aefc49a2c7b4ff633a56934e4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 10027, "upload_time": "2018-10-28T21:08:32", "url": "https://files.pythonhosted.org/packages/e5/18/4e0b9f7927c0d5c5c8a67ecdb3f1a6e7412bda488498180e98bc70061eac/figcan-0.0.1-py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "2fbed93d235adacd1f11b43340ce552f", "sha256": "ecbf3c71b8994707038c1ce69d2e248b251e106fe1fe3d1a224f7bb533dcbbf4" }, "downloads": -1, "filename": "figcan-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2fbed93d235adacd1f11b43340ce552f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10128, "upload_time": "2018-10-29T12:45:04", "url": "https://files.pythonhosted.org/packages/41/60/8a2881b32f40f3d4cd843a8656de754bd5407fe3e73db5afc26f9ef3dac4/figcan-0.0.2-py2.py3-none-any.whl" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "9d4e35b892cd2269470f948815c0421f", "sha256": "2fb46ba6b479923e88fff8551582f7bd6112018b2deb2f3a756645cd372f8c3f" }, "downloads": -1, "filename": "figcan-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9d4e35b892cd2269470f948815c0421f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10280, "upload_time": "2018-10-29T13:36:15", "url": "https://files.pythonhosted.org/packages/b6/43/10906f9dac01316a2151dadfc65209b2b22578f0b6879a54d99f7d18326c/figcan-0.0.3-py2.py3-none-any.whl" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "47b61db4c9392ab3ada072e7bd5629a6", "sha256": "58f38c21f214cc5e26d631391c219febe96502dbf4389211145ee69a44bc5ebe" }, "downloads": -1, "filename": "figcan-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47b61db4c9392ab3ada072e7bd5629a6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10823, "upload_time": "2018-11-01T09:54:07", "url": "https://files.pythonhosted.org/packages/54/0e/73c426f0186f83a788ec9ea924b1ae0cead61233c88bbf537fef7db92655/figcan-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc53b6d36cd0d49b614525f06d4d414d", "sha256": "c41169803f9885b614fba674a564c7085495c8ed38fff55949362d9f08f48a9f" }, "downloads": -1, "filename": "figcan-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "fc53b6d36cd0d49b614525f06d4d414d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10818, "upload_time": "2018-10-31T15:15:43", "url": "https://files.pythonhosted.org/packages/4c/23/0b70c93d4aeacde3e21303be1f84c1a65e212ee360795fc002a54b763fa8/figcan-0.0.4-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47b61db4c9392ab3ada072e7bd5629a6", "sha256": "58f38c21f214cc5e26d631391c219febe96502dbf4389211145ee69a44bc5ebe" }, "downloads": -1, "filename": "figcan-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47b61db4c9392ab3ada072e7bd5629a6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10823, "upload_time": "2018-11-01T09:54:07", "url": "https://files.pythonhosted.org/packages/54/0e/73c426f0186f83a788ec9ea924b1ae0cead61233c88bbf537fef7db92655/figcan-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc53b6d36cd0d49b614525f06d4d414d", "sha256": "c41169803f9885b614fba674a564c7085495c8ed38fff55949362d9f08f48a9f" }, "downloads": -1, "filename": "figcan-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "fc53b6d36cd0d49b614525f06d4d414d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 10818, "upload_time": "2018-10-31T15:15:43", "url": "https://files.pythonhosted.org/packages/4c/23/0b70c93d4aeacde3e21303be1f84c1a65e212ee360795fc002a54b763fa8/figcan-0.0.4-py3-none-any.whl" } ] }