{ "info": { "author": "Nickolas Grigoriadis", "author_email": "nagrigoriadis@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "#######\nconfigy\n#######\n\nSimple Configuration manager, plays well with testing.\n\n.. image:: https://travis-ci.org/grigi/configy.svg\n :target: https://travis-ci.org/grigi/configy?branch=master\n.. image:: https://coveralls.io/repos/grigi/configy/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/grigi/configy?branch=master\n\n\nBasic Usage\n===========\n\nInstall from pypi:\n\n.. code-block:: shell\n\n pip install configy\n\nSpecify the configuration directives as early in execution as possible:\n\n.. code-block:: python\n\n import configy\n \n try:\n # Every option is optional, fill in as makes sense.\n configy.load_config(\n conf='the_configuration.yaml', # The default config file if not specified as an ENV var\n env='CONFIGY_FILE', # The ENV var to look for a config file\n defaults='defaults.yaml', # The defaults that is always loaded.\n data={'manual': 'defaults'}, # Manually provided defaults loaded\n case_sensitive=True # Case Sensitive by default\n )\n except configy.ConfigyError as e:\n # Report config load error to user\n \nGiven a sample YAML config file of:\n\n.. code-block:: YAML\n\n Something:\n value: The Value\n number: 42\n bool1: 1\n bool2: FALSE\n bool3: y\n\nYou then use it so:\n\n.. code-block:: python\n\n >>> from configy import config\n >>> config.Something.value\n 'The Value'\n\nIf you try to access any configuration value that isn't defined you will get an exception:\n\n.. code-block:: python\n\n >>> config.Something.other\n Traceback (most recent call last):\n File \"\", line 1, in \n KeyError: 'other'\n\nThe config object is just a dictionary, so you can use it as a regular dictionary as well:\n\n.. code-block:: python\n\n >>> config['Something']['value']\n 'The Value'\n >>> config.Something.get('other', 'default value')\n 'default value'\n\n\nHelper functions\n----------------\n\nSince you can't guarantee the type of a value in the configuration files (YAML treats everything as text), you need to do type conversion manually.\n\nFor ints and floats it is easy:\n\n.. code-block:: python\n\n >>> int(config.Something.number)\n 42\n >> float(config.Something.number)\n 42.0\n\nFor booleans it is a bit more tricky, as a boolean can be represented by many different notations. You also don't have complete control over the notation used. For this we provide a ``to_bool()`` helper function.\n\nIt treats case-insensitively \n\n``True``\n 'y', 'yes', '1', 't','true'\n``False``\n 'n', 'no', '0', 'f', 'false'\n\nAnything else will resort to the provided default (which defaults to False)\n\n.. code-block:: python\n\n >>> from configy import config, to_bool\n >>> to_bool(config.Something.bool1)\n True\n >>> to_bool(config.Something.bool2)\n False\n >>> to_bool(config.Something.bool1)\n True\n >>> to_bool(config.Something.number)\n False\n >>> to_bool(config.Something.number, True)\n True\n >>> to_bool(config.Something.number, None)\n None\n\n\nHow to overload settings for testing\n====================================\n\nDuring testing, one often wants to override some configuration to test something specific.\nConfigy supports this use case.\n\n.. code-block:: python\n\n from configy import config, testconfig\n \n @testconfig.override_config({\n 'Something': {\n 'other': 'I now exist',\n },\n 'Extra': 'defined',\n })\n def test_override():\n # Existing values still work as per usual\n assert config.Something.value == 'The Value'\n # New values \n assert config.Something.other == 'I now exist'\n assert config.Extra == 'defined'\n\nOne can also define configuration to be used:\n\n.. code-block:: python\n\n @testconfig.load_config(\n conf='test_config.yaml'\n )\n def test_load_config():\n assert config.testvalue == 'test result'\n\nYou can also define the WHOLE configuration that is loaded for that test:\n\n.. code-block:: python\n\n @testconfig.load_config(data={\n 'testvalue': 'test result',\n })\n def test_load_config_data():\n assert config.testvalue == 'test result'\n\nAll the testing decorators will work on method, class and function level.", "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/grigi/configy", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "configy", "package_url": "https://pypi.org/project/configy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/configy/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/grigi/configy" }, "release_url": "https://pypi.org/project/configy/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Simple Configuration manager, plays well with testing", "version": "0.1.1" }, "last_serial": 2007504, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "db78ad12f4d061c2331f7bde3b63ec76", "sha256": "d2bac6144acc2f6d1975082db2f95bf651182be17b190b926dca2f1931ac9002" }, "downloads": -1, "filename": "configy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "db78ad12f4d061c2331f7bde3b63ec76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6517, "upload_time": "2015-09-08T07:13:53", "url": "https://files.pythonhosted.org/packages/1a/11/aa7097fcda560e96f9d24e2a9dee8b03de279354c7458ed05f84057473ed/configy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ef923b49f05e0a6b348934686fd3b61d", "sha256": "48e1bf3c69afb1cbd8d0685c21d9b28651739340b2253f34d3989235c9564bed" }, "downloads": -1, "filename": "configy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ef923b49f05e0a6b348934686fd3b61d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6759, "upload_time": "2016-03-15T09:26:18", "url": "https://files.pythonhosted.org/packages/b9/53/3534abed00cf7a1c995d9fea6efa1f3369974e4d05ef6566210bc510f4af/configy-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ef923b49f05e0a6b348934686fd3b61d", "sha256": "48e1bf3c69afb1cbd8d0685c21d9b28651739340b2253f34d3989235c9564bed" }, "downloads": -1, "filename": "configy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ef923b49f05e0a6b348934686fd3b61d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6759, "upload_time": "2016-03-15T09:26:18", "url": "https://files.pythonhosted.org/packages/b9/53/3534abed00cf7a1c995d9fea6efa1f3369974e4d05ef6566210bc510f4af/configy-0.1.1.tar.gz" } ] }