{ "info": { "author": "Berislav Lopac", "author_email": "berislav@lopac.net", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# figga\n\nA very simple configuration manager for Python.\n\n[![Travis CI build](https://www.travis-ci.org/berislavlopac/figga.svg?branch=master)](https://www.travis-ci.org/berislavlopac/figga)\n\n\n## Usage\n\n`figga` currently supports three ways of specifying the configuration:\n\n* standard Python dictionary\n* environment variables with a common prefix\n* one or more `INI` files\n\n\n### Basic Usage\n\nThe default mechanism of instantiating a `figga.Configuration` instance is passing a simple Python dictionary:\n\n from figga import Configuration\n\n config = Configuration({'foo': 'bar', 'var1': 123, 'VAR2': 'buzz'})\n\nThis mechanism can be easily used to store configuration in any file format which can easily be converted to a `dict`, such as JSON or YAML:\n\n import json\n from figga import Configuration\n\n with open('config.json') as json_config:\n config = Configuration(json.load(json_config))\n\nThe instantiated object can be used from elsewhere in your code, e.g. if the above instantiation happened in module `somewhere.py`:\n\n from somewhere import config\n\n print(config.some_value)\n\nNote that all variable names are normalised to lowercase, and access is case insensitive: `config.foo`, `config.FOO` or `config.Foo` all point to the same value.\n\nIn addition to direct access, values can be retrieved using the `get` method:\n\n config.get('some_value')\n\nNote that `get` also accepts the `default` argument, the value of which will override the default value specified at instantiation (see below).\n\n\n### Default Values\n\nAll constructor methods accept the argument `default`, which defines the behaviour when a non-existing value is accessed. This argument can handle three different types of default values:\n\n* any object or scalar value, which will be returned as-is\n* a callable, which will be called passing the accessed variable name as the only argument, returning its result\n* a `BaseException` subclass, which will be raised instead of returning a value\n\nIf no default value is specified, an unknown variable will have the value of `None`.\n\n\n### From Environment Variables\n\nAnother option to initialize the configuration manager is by taking the values of all the environment variables which begin with a common prefix:\n\n import os\n from figga import Configuration\n\n os.environ['YOURAPP_VARIABLE'] = 'foo bar'\n\n config = Configuration.from_environ(prefix='YOURAPP_')\n\n print(config.yourapp_variable)\n\nOptionally you can remove the prefix from the final configuration variables:\n\n config = Configuration.from_environ(prefix='YOURAPP_', remove_prefix=True)\n\n print(config.variable)\n\n\n### From INI Files\n\nAlternatively, `figga.Configuration` can be instantiated using one or more [configparser](https://docs.python.org/3/library/configparser.html)-compatible files:\n\n from figga import Configuration\n\n config = Configuration.from_files('config1.ini', '/vars/config2.ini')\n\nIf the file paths are not absolute, they are assumed to be relative to the current working directory. Paths can be either strings or `os.PathLike` instances.\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/berislavlopac/figga", "keywords": "configuration,config", "license": "MIT", "maintainer": "Berislav Lopac", "maintainer_email": "berislav@lopac.net", "name": "figga", "package_url": "https://pypi.org/project/figga/", "platform": "", "project_url": "https://pypi.org/project/figga/", "project_urls": { "Homepage": "https://github.com/berislavlopac/figga" }, "release_url": "https://pypi.org/project/figga/0.1.2/", "requires_dist": null, "requires_python": ">= 3.6.0.0, < 4.0.0.0", "summary": "A simple configuration manager for Python.", "version": "0.1.2" }, "last_serial": 3842215, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a0a9dff3a53d860f1005f162d492856c", "sha256": "dcf4beed621d5f2635f7a5f3c00157f025bd8610df6890edd5d6b5dabeb647e1" }, "downloads": -1, "filename": "figga-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a0a9dff3a53d860f1005f162d492856c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 4938, "upload_time": "2018-05-07T20:24:16", "url": "https://files.pythonhosted.org/packages/e4/7a/8b53eb4bdffb9e8c2f000db34f3d598197b7fb16e1987f20281b89c0d294/figga-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5609a22b0d48a260f2d636d646fa8845", "sha256": "bc55543b3907e3e866c568796d9691546758f0815468ee6d752eb9d22ad89dd8" }, "downloads": -1, "filename": "figga-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5609a22b0d48a260f2d636d646fa8845", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 3158, "upload_time": "2018-05-07T20:24:15", "url": "https://files.pythonhosted.org/packages/8d/88/2aadaa3efbb05595f711842b8bb60d4cf95d0cbae7a518331c47cdad1aeb/figga-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b57e2c87e08046825e2bb1d322b6aecf", "sha256": "2d913e88982e0d2dde8caa116d611aea0e094929555d1d57218b1f662f8d4e6b" }, "downloads": -1, "filename": "figga-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b57e2c87e08046825e2bb1d322b6aecf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 4939, "upload_time": "2018-05-07T20:55:42", "url": "https://files.pythonhosted.org/packages/0a/5c/0bb72880a4ee0991e3f2178aa1148b0fdd7007c0a133c18128186baa3156/figga-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "afaa2e925a4c2064409c74ff840b3b64", "sha256": "fcae7d39fb727d64c1f2bb680b70dbe7bf76a1ff312ec95036b0316eacdebfd7" }, "downloads": -1, "filename": "figga-0.1.1.tar.gz", "has_sig": false, "md5_digest": "afaa2e925a4c2064409c74ff840b3b64", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 3168, "upload_time": "2018-05-07T20:55:43", "url": "https://files.pythonhosted.org/packages/d4/30/512e9ace5e1c9982dc4f1b637e3ebe372cae0b049aab7340c5255848d61b/figga-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "a8b342f99e1a52d379f57927f2c69bb3", "sha256": "121a7953a2b7d5273e98b26e23ff8b4d7258aa9da469dbf909d9f8bfaa6efceb" }, "downloads": -1, "filename": "figga-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a8b342f99e1a52d379f57927f2c69bb3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 4940, "upload_time": "2018-05-07T21:15:11", "url": "https://files.pythonhosted.org/packages/4c/a9/637d144e24dbf4ab8174bb984145b4a000337b953c58660bb5df95ef82b1/figga-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31fb33ef85457087ef90a093315fcf65", "sha256": "cd8e67e36fe916cb01eb5ec559084611d76671acb9ba1aa2bb0e8262d408400a" }, "downloads": -1, "filename": "figga-0.1.2.tar.gz", "has_sig": false, "md5_digest": "31fb33ef85457087ef90a093315fcf65", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 3176, "upload_time": "2018-05-07T21:15:12", "url": "https://files.pythonhosted.org/packages/76/f4/6b67bd6a5b25f78e64b0a16c2f82aadaad176b07c70143fe3e1185d45d7b/figga-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a8b342f99e1a52d379f57927f2c69bb3", "sha256": "121a7953a2b7d5273e98b26e23ff8b4d7258aa9da469dbf909d9f8bfaa6efceb" }, "downloads": -1, "filename": "figga-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a8b342f99e1a52d379f57927f2c69bb3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 4940, "upload_time": "2018-05-07T21:15:11", "url": "https://files.pythonhosted.org/packages/4c/a9/637d144e24dbf4ab8174bb984145b4a000337b953c58660bb5df95ef82b1/figga-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31fb33ef85457087ef90a093315fcf65", "sha256": "cd8e67e36fe916cb01eb5ec559084611d76671acb9ba1aa2bb0e8262d408400a" }, "downloads": -1, "filename": "figga-0.1.2.tar.gz", "has_sig": false, "md5_digest": "31fb33ef85457087ef90a093315fcf65", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.6.0.0, < 4.0.0.0", "size": 3176, "upload_time": "2018-05-07T21:15:12", "url": "https://files.pythonhosted.org/packages/76/f4/6b67bd6a5b25f78e64b0a16c2f82aadaad176b07c70143fe3e1185d45d7b/figga-0.1.2.tar.gz" } ] }