{ "info": { "author": "Oleiade", "author_email": "tcrevon@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "===============================\nEtcaetera\n===============================\n\n.. image:: https://badge.fury.io/py/etcaetera.png\n :target: http://badge.fury.io/py/etcaetera\n \n.. image:: https://travis-ci.org/oleiade/etcaetera.png?branch=master\n :target: https://travis-ci.org/oleiade/etcaetera\n\n.. image:: https://pypip.in/d/etcaetera/badge.png\n :target: https://crate.io/packages/etcaetera?version=latest\n\n\nWhat?\n=====\n\nEtcaetera is the simplest way for you to load your application configuration from multiple sources.\n\nIt exposes a single **Config** object to which you add prioritized sources adapters (env, files, cmdline, modules...).\n\nOnce you call ``load`` method on it: your settings are loaded from your adapters in the right order, all your configuration is stored in the **Config** object.\n\nYou're **done**.\n\n\nWhy?\n====\n\nManaging a large application configuration sources can be a pain in the neck.\n\nCommand line, files, system environment, modules, the settings you seek come from a lot of mixed sources.\n\nThey all have a different accessing mode and merging them can sometimes seem impossible !\n\nEtcaetera provides you with a simple and unified way to handle all the complexity in a single place.\n\n\nInstallation\n============\n\nWith pip\n--------\n\n.. code-block:: bash\n\n $ pip install etcaetera\n\nWith setuptools\n---------------\n\n.. code-block:: bash\n\n $ git clone git@github.com:oleiade/etcaetera\n $ cd etcaetera\n $ python setup.py install\n\n\nUsage\n=====\n\nDive\n----\n\nA real world example is worth a thousand words\n\n.. code-block:: python\n\n >>> import os\n >>> from etcaetera.config import Config\n >>> from etcaetera.adapter import Defaults, Module, Overrides, Env, File\n\n # Let's create a new configuration object\n >>> config = Config()\n\n # And create a bunch of adapters\n >>> env_adapter = Env(\"MY_FIRST_SETTING\", \"MY_SECOND_SETTING\")\n >>> python_file_adapter = File('/etc/my/python/settings.py')\n >>> json_file_adapter = File('/etc/my_json_settings.json')\n >>> module_adapter = Module(os)\n >>> overrides = Overrides({\"MY_FIRST_SETTING\": \"my forced value\"})\n\n # Let's register them\n >>> config.register(env_adapter, python_file_adapter, json_file_adapter, module_adapter, overrides)\n\n # Load configuration\n >>> config.load()\n\n # And that's it\n >>> print(config)\n {\n \"MY_FIRST_SETTING\": \"my forced value\",\n \"MY_SECOND_SETTING\": \"my second value\",\n \"FIRST_YAML_SETTING\": \"first yaml setting value found in yaml settings\",\n \"FIRST_JSON_SETTING\": \"first json setting value found in json settings\",\n ...\n }\n\nConfig object\n-------------\n\nThe config object is the central place for your whole application settings. It will load your adapters\nin the order you've registered them, and update itself using it's data. Furthermore you can attach sub config\nobjects to it, in order to keep a clean configuration hierarchy.\n\nPlease note that **Defaults** adapter will always be loaded first, and **Overrides** will always be loaded last.\n\n.. code-block:: python\n\n >>> from etcaetera.config import Config\n >>> from etcaetera.adapter import Defaults, Env\n\n # Create a Config object\n >>> config = Config()\n\n # Let's register adapters to it. When adapters are registered on a Config\n # they are not immediately evaluated.\n >>> config.register(Defaults({\"ABC\": \"123\"}))\n >>> assert \"ABC\" not in config\n >>> config.register(Env(\"USER\", \"PWD\")\n >>> assert \"USER\" not in config\n >>> assert \"PWD\" not in config\n\n # We can see that our adapters registration has been taken in account\n >>> config.adapters\n AdapterSet(, )\n\n # Whenever you call load, adapters are evaluated in the order you've\n # registered them, and your config values are updated accordingly\n >>> config.load()\n >>> print(config)\n {\n \"ABC\": \"123\",\n \"USER\": \"your user\",\n \"PWD\": \"/current/working/directory\"\n }\n\n # If you need a certain hierarchy for your configuration\n # Config objects supports sub configs. Here's an example of\n # how to add an \"aws\" subconfig\n >>> aws_config = Config() # Create a config obj\n >>> aws_env = Env(\"AWS_ACCESS_KEY_ID\", \"AWS_SECRET_ACCESS_KEY\")\n >>> aws_config.register(aws_env) # Register an env adapter on to it\n >>> config.add_subconfig('aws', aws_config)\n >>> config.aws\n {\n \"AWS_ACCESS_KEY_ID\": \"128u09ijod019jhd182o1290d81\",\n \"AWS_SECRET_ACCESS_KEY\": \"qoiejdn0182hern1d098uj12podij1029udaiwjJBIU09u0oimJHKI\"\n }\n\n # Config objects are also able to automatically format the keys incoming\n # from adapters. For example if you'd want all your keys to be lowercased\n # just pass it the appropriate formatter (from etcaetera.formatters import *)\n >>> from etcaetera.formatters import lowercased\n >>> formatted_config = Config(formatter=lowercased)\n >>> env_adapter = Env(**{\"USER\": \"SUPER_DUPER_USER\"})\n >>> formatted_config.register(env_adapter)\n >>> formatted_config.load()\n >>> print formatted_config\n {\n \"super_duper_user\": \"oleiade\",\n }\n\nAdapters\n--------\n\nAdapters are the interfaces with configuration sources. They load settings from their custom source type,\nand they expose them as a normalized dict to *Config* objects.\n\nRight now, etcaetera provides the following adapters:\n * *Defaults*: sets some default settings\n * *Overrides*: overrides the config settings values\n * *Env*: extracts configuration values from system environment\n * *File*: extracts configuration values from a file. Accepted format are: json, yaml, python module file (see *File adapter* section for more details)\n * *Module*: extracts configuration values from a python module. Like in django, only uppercased variables will be matched\n\nIn a close future, etcaetera may provide adapters for:\n * *Argv* argparse format support: would load settings from an argparser parser attributes\n * *File* ini format support: would load settings from an ini file\n\nCool features you should know about:\n * You can provide a *formatter* to your adapters so the imported keys will be automatically modified. Example ``Env(\"USER\", etcaetera.formatters.lowercased)`` will import the ``$USER`` environment variable as ``user`` when ``.load()`` is called. \n\nDefaults adapter\n~~~~~~~~~~~~~~~~\n\nDefaults adapter provides your configuration object with default values.\nIt will always be evaluated first when ``Config.load`` method is called.\nYou can whether provide defaults values to *Config* as a *Defaults* object\nor as a dictionary.\n\n.. code-block:: python\n\n >>> from etcaetera.config import Config\n >>> from etcaetera.adapter import Defaults\n\n # Defaults adapter provides default configuration settings\n >>> defaults = Defaults({\"ABC\": \"123\"})\n\n >>> config = Config(defaults)\n >>> config.load()\n\n >>> print(config)\n {\n \"ABC\": \"123\"\n }\n\nOverrides adapter\n~~~~~~~~~~~~~~~~~\n\nThe Overrides adapter overrides *Config* object values with it's own values.\nIt will always be evaluated last when the ``Config.load`` method is called.\n\n.. code-block:: python\n\n >>> from etcaetera.config import Config\n >>> from etcaetera.adapter import Overrides\n\n # The Overrides adapter helps you set overriding configuration settings.\n # When registered over a Config objects, it will always be evaluated last.\n # Use it if you wish to force some config values.\n >>> overrides_adapter = Overrides({\"USER\": \"overrided value\"})\n >>> config = Config({\n \"USER\": \"default value\",\n \"FIRST_SETTING\": \"first setting value\"\n })\n\n >>> config.register(overrides_adapter)\n >>> config.load()\n\n >>> print(config)\n {\n \"USER\": \"overrided value\",\n \"FIRST_SETTING\": \"first setting value\"\n }\n\nEnv adapter\n~~~~~~~~~~~\n\nEnv adapter loads configuration variables values from system environment.\nYou can whether provide it a list of keys to be fetched from environment. Or you can pass it a *environment variables name to adapter destination name* ``**mappings`` dict.\nMoreover, as adapters support nested keys through the ``.`` separator you can map any env var to a nested adapter destination.\n\n.. code-block:: python\n\n >>> from etcaetera.adapter import Env\n\n # You can provide keys to be fetched by the adapter at construction\n # as keys\n >>> env = Env(\"USER\", \"PATH\")\n >>> env.load()\n >>> print env.data\n {\n \"USER\": \"user extracted from environment\",\n \"PATH\": \"path extracted from environment\",\n \"PWD\": \"pwd extracted from environment\"\n }\n\n # alternatively pass it as env var names to adapter var \n # names dict\n >>> os.environ[\"SOURCE\"], os.environ[\"OTHER_SOURCE\"]\n (\"my first value\", \"my second value\")\n >>> env = Env({\"SOURCE\": \"DEST\", \"OTHER_SOURCE\": \"TEST\"})\n >>> env.load()\n >>> print env.data\n {\n \"DEST\": \"my first value\",\n \"TEST\": \"my second value\"\n }\n\n # Adapters support nested destination too\n >>> env = Env({\"MY.USER\": \"USER\"})\n >>> env.load()\n >>> print env.data\n {\n \"MY\": {\n \"USER\": \"oleiade\",\n }\n }\n\nFile adapter\n~~~~~~~~~~~~\n\nThe File adapter will load the configuration settings from a file.\nSupported formats are json, yaml and python module files. Every key-value pairs\nstored in the pointed file will be loaded in the *Config* object it is registered to.\n\nPython module files\n```````````````````\n\nThe Python module files should be in the same format as the Django settings files. Only uppercased variables\nwill be loaded. Any python data structures can be used.\n\n*Here's an example*\n\n*Given the following settings.py file*\n\n.. code-block:: bash\n\n $ cat /my/settings.py\n FIRST_SETTING = 123\n SECOND_SETTING = \"this is the second value\"\n THIRD_SETTING = {\"easy as\": \"do re mi\"}\n ignored_value = \"this will be ignore\"\n\n*File adapter output will look like this*:\n\n.. code-block:: python\n\n >>> from etcaetera.adapter import File\n\n >>> file = File('/my/settings.py')\n >>> file.load()\n\n >>> print(file.data)\n {\n \"FIRST_SETTING\": 123,\n \"SECOND_SETTING\": \"this is the second value\",\n \"THIRD_SETTING\": {\"easy as\": \"do re mi\"}\n }\n\nSerialized files (aka json and yaml)\n````````````````````````````````````\n\n*Given the following json file content*:\n\n.. code-block:: bash\n\n $ cat /my/json/file.json\n {\n \"FIRST_SETTING\": \"first json file extracted setting\",\n \"SECOND_SETTING\": \"second json file extracted setting\"\n }\n\n*The File adapter output will look like this*:\n\n.. code-block:: python\n\n >>> from etcaetera.adapter import File\n\n # The File adapter awaits on a file path at construction.\n # All you have to do then, is to let the magic happen\n >>> file = File('/my/json/file.json')\n >>> file.load()\n\n >>> print(file.data)\n {\n \"FIRST_SETTING\": \"first json file extracted setting\",\n \"SECOND_SETTING\": \"second json file extracted setting\"\n }\n\nModule adapter\n~~~~~~~~~~~~~~\n\nThe Module adapter will load settings from a python module. It emulates the django\nsettings module loading behavior, so that every uppercased locals of the module is matched.\n\n**Given a mymodule.settings module looking this**:\n\n.. code-block:: python\n\n MY_FIRST_SETTING = 123\n MY_SECOND_SETTING = \"abc\"\n\n**Loaded module data will look like this**:\n\n.. code-block:: python\n\n >>> import mymodule\n >>> from etcaetera.adapter import Module\n\n # It will extract all of the module's uppercased local variables\n >>> module = Module(mymodule.settings)\n >>> module.load()\n\n >>> print(module.data)\n {\n MY_FIRST_SETTING = 123\n MY_SECOND_SETTING = \"abc\"\n }\n\n\nContribute\n==========\n\nPlease read the `Contributing `_ instructions\n\nIf you are lazy, here's a summary:\n\n1. Found a bug? Want to add a feature? Check for open issues or open a fresh one to start a discussion about it.\n2. Fork the repository, and start making your changes.\n3. Write some tests showing you fixed the current bug or your feature works as expected.\n4. Fasten your seatbelt, and send a pull request to the *develop* branch.\n\n\nLicense\n=======\nThe MIT License (MIT)\n\nCopyright (c) 2014 Th\u00e9o Crevon\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nCredits and thanks\n==================\n\nEtcaetera is freely inspired (and could be considered as a port of) by [Conf](https://github.com/jingweno/conf).\nFirst of all thanks to it's author. And thanks to @botify who supported the creation of this open-source library.\n\n\n.. image:: https://d2weczhvl823v0.cloudfront.net/oleiade/etcaetera/trend.png\n :alt: Bitdeli badge\n :target: https://bitdeli.com/free\n\n\n\n\n\nHistory\n-------\n\n0.1.0 (2014-01-11)\n++++++++++++++++++\n\n* First release on PyPI.", "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/oleiade/etcaetera", "keywords": "etcaetera", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "etcaetera", "package_url": "https://pypi.org/project/etcaetera/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/etcaetera/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/oleiade/etcaetera" }, "release_url": "https://pypi.org/project/etcaetera/0.4.3/", "requires_dist": null, "requires_python": null, "summary": "Manage multiple configuration sources in a single place", "version": "0.4.3" }, "last_serial": 1070212, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "99b38ced610cfa88a290b671cb6a124d", "sha256": "36e7194c27bd89c3a5441ae983daf21fd886dbe13333822f27589391041c0d0b" }, "downloads": -1, "filename": "etcaetera-0.1.0.tar.gz", "has_sig": false, "md5_digest": "99b38ced610cfa88a290b671cb6a124d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9613, "upload_time": "2014-02-25T13:57:46", "url": "https://files.pythonhosted.org/packages/2b/2e/cd88e4e464f9ceb41fdfdc7fe85635525e88174eac08cb2d0e57b35b61fc/etcaetera-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "bf7f1f1e73a96123fea929f10d50a733", "sha256": "bd534b2eda4d51e22b7f0e889278c9ed46c257bd1610fd339c096a912a53cd04" }, "downloads": -1, "filename": "etcaetera-0.2.0.tar.gz", "has_sig": false, "md5_digest": "bf7f1f1e73a96123fea929f10d50a733", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10495, "upload_time": "2014-03-05T10:22:37", "url": "https://files.pythonhosted.org/packages/f6/67/96127115c19cbdee86564b00d3ca3535bd0acb05669365693c1e9573e9b5/etcaetera-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "f9af45e8d8acfcba52a532c4af72ea57", "sha256": "07c6cd6cd1a6cb819b48cc7261dfe17f0443d38e2d825246e20fb2fb80d17dcb" }, "downloads": -1, "filename": "etcaetera-0.3.0.tar.gz", "has_sig": false, "md5_digest": "f9af45e8d8acfcba52a532c4af72ea57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11612, "upload_time": "2014-04-03T13:35:31", "url": "https://files.pythonhosted.org/packages/05/e0/6d2d4832ebe794c10497be96a9a8483f7c332fedb3b44f32afb00a21bdee/etcaetera-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "7e23e482020bf50315d6c14ffa837494", "sha256": "7b0c45e4b55d2e175e122accd070a7167703de152c10aff2747370e579885830" }, "downloads": -1, "filename": "etcaetera-0.3.1.tar.gz", "has_sig": false, "md5_digest": "7e23e482020bf50315d6c14ffa837494", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12104, "upload_time": "2014-04-08T10:51:10", "url": "https://files.pythonhosted.org/packages/ab/38/cb789d577bf30bf562cdf48d2e592e346ec70036c75d9f252a43703fd4ca/etcaetera-0.3.1.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "679c6a471ebdd0c04fff9dd26609ae21", "sha256": "7f177cbeef452b50e29e039e3f0059d15cfa9af0152b74e82d84bbeffe27df6e" }, "downloads": -1, "filename": "etcaetera-0.4.0.tar.gz", "has_sig": false, "md5_digest": "679c6a471ebdd0c04fff9dd26609ae21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12611, "upload_time": "2014-04-08T15:02:53", "url": "https://files.pythonhosted.org/packages/bd/f6/667922101b17d94395106867b638808fe936a1a2d6e5e17ec46f33777cc9/etcaetera-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "157d82b66e8e42260df83e0fdb9a0916", "sha256": "2a3e93167abde46771bc4ae019fe62aee76ad285d5385d912e024c9f6001d29b" }, "downloads": -1, "filename": "etcaetera-0.4.1.tar.gz", "has_sig": false, "md5_digest": "157d82b66e8e42260df83e0fdb9a0916", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12917, "upload_time": "2014-04-23T10:01:20", "url": "https://files.pythonhosted.org/packages/29/e6/dd5be753a90e5020702bf7b4a76bc6084aa7b361fbac0018a446af3bd540/etcaetera-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "572721877def5d0ce9c9dcfd13e6750c", "sha256": "0e78b04ce6fb0e0266e967bd7276cb41e6ba121fd17500cd5540a30fe07c1344" }, "downloads": -1, "filename": "etcaetera-0.4.2.tar.gz", "has_sig": false, "md5_digest": "572721877def5d0ce9c9dcfd13e6750c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12769, "upload_time": "2014-04-23T15:34:13", "url": "https://files.pythonhosted.org/packages/18/19/ffe5dc675d9156aa8cc2b53e15cbfd1592e7ab557772cfa31544d0389510/etcaetera-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "7ce8789d3fa92b01557a0ae529101fac", "sha256": "3fff72eafe7015683402041eb1ce1a920dd38bf4aaba686c00bf0be8c11fcb0e" }, "downloads": -1, "filename": "etcaetera-0.4.3.tar.gz", "has_sig": false, "md5_digest": "7ce8789d3fa92b01557a0ae529101fac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13072, "upload_time": "2014-04-24T09:52:15", "url": "https://files.pythonhosted.org/packages/cb/b8/d9286f8bc2c55bdf8f4d1953031b1d553303b660b326c60070d9467569d2/etcaetera-0.4.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7ce8789d3fa92b01557a0ae529101fac", "sha256": "3fff72eafe7015683402041eb1ce1a920dd38bf4aaba686c00bf0be8c11fcb0e" }, "downloads": -1, "filename": "etcaetera-0.4.3.tar.gz", "has_sig": false, "md5_digest": "7ce8789d3fa92b01557a0ae529101fac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13072, "upload_time": "2014-04-24T09:52:15", "url": "https://files.pythonhosted.org/packages/cb/b8/d9286f8bc2c55bdf8f4d1953031b1d553303b660b326c60070d9467569d2/etcaetera-0.4.3.tar.gz" } ] }