{ "info": { "author": "Adam Venturella", "author_email": "aventurella@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# confypy\n\nPython **2.6**, **2.7**, **3.2** and **3.3** compatible\n\n## Simple Configuration Loading and Management\n\n\n## Usage\n\nOnce a config is configured with locations, it's values are accessed through\nthe `data` attribute. Key or Attribute access is valid:\n\n```python\nfrom confypy import Config\nfrom confypy import Location\n\nconfig = Config()\nconfig.locations = [Location.from_env_keys(['FOO', 'BAR', 'BAZ'])]\n\nprint(config.data.FOO)\nprint(config.data.BAR)\nprint(config.data.BAZ)\n\n# OR\n\nprint(config.data['FOO'])\nprint(config.data['BAR'])\nprint(config.data['BAZ'])\n\n```\n\n## Built-In Parsers\nBy *built-in*, we mean confypy will automatically check for common\nconfig parsers of the following types:\n\n- json (falls back to simplejson)\n- yaml (pyyaml required)\n- configparser (Python's own ConfigParser)\n- python (load a module's __dict__)\n\nIt determines the parser to use by checking the file extension of\nany file paths. However, you are also free to override this.\n\nThe parser can manually be set in the Location.* declaration.\n\nFor example, each of the following assumes JSON:\n\n```python\nLocation.from_path('/data/foo.json')\n```\n\nSo does this:\n```python\nLocation.from_path('/data/foo', parser='json')\n```\n\nAnd so does this:\n\n```python\nimport json\nLocation.from_path('/data/foo', parser=json.loads)\n```\n\nAnd this too:\n*Note that the imported 'json' here is just a reference to the json.loads callable*\n\n```python\nimport json\nfrom confypy import Location\nfrom confypy.loaders import load_file\nfrom confypy.parsers import json\n\nlocation = Location('data/foo', loader=load_file, parser=json)\n\n```\n\nYes, the parser argument to Location can be a `string` OR a `callable`.\nIn fact, the various Location.* factories just handle passing the parser\narg for you.\n\nParsers are chosen from strings and file extensions with the following\nrules: (see confypy.parsers.parser_for_ext)\n\n```python\ndef parser_for_ext(ext):\n\n mapping = {\n 'yml': yaml,\n 'yaml': yaml,\n 'json': json,\n 'ini': configparser,\n 'configparser': configparser\n }\n\n result = mapping.get(ext.lower(), None)\n\n if result:\n return result\n\n raise ParserNotFound(ext)\n```\n\n\n## Defaults\n\nEach config supports a set of defaults provided at creation time.\n\n```python\nfrom confypy import Config\nfrom confypy import Location\n\n\ndefaults = {'foo':1, 'bar':2, 'baz':3}\nconfig = Config(defaults=defaults)\n```\n\nIf no locations are present, or if none of the locations, when loaded, return\nany valid data, the defaults will be when looking up values.\n\nWhen locations are chained, the defaults represent the last location for a\nlookup before an error is raised.\n\n\n## Examples\n\n\n#### Stop loading after the 1st successful load.\n\nIn the example below, the `TEST_SETTINGS` environment variable will be\nchecked first. It's assumed that it's value will be a file path:\n`from_env_path`. It's also possible to just load environment variables\nas key/values which will follow in another example.\n\nSo `TEST_SETTINGS` will be checked first, if the file exists, the drama\nstops there. If it doesn't exist, it moves on to the next Location\nprovided in the locations list.\n\nAssuming our file contains this JSON:\n\n```json\n{\n \"name\": \"Lucy\"\n}\n```\n\nWe can do this:\n\n```python\nfrom confypy import Config\nfrom confypy import Location\n\nconfig = Config()\nconfig.locations = [\n Location.from_env_path('TEST_SETTINGS'),\n Location.from_path('/data/foo.json')\n]\n\nprint(config.data.name)\n```\n\n#### Try to load everything and chain the results together.\n\nThe resultant config can be chained. Values will be looked up starting\nfrom the last location provided in the locations list, falling **up**\nto the first location provided in the location list.\n\nIn other words the lookup order is like this in a chain:\n\n```python\nfrom confypy import Config\nfrom confypy import Location\n\nconfig = Config(chain=True)\nconfig.locations = [\n Location.from_env_path('TEST_SETTINGS'), # 5\n Location.from_path('/data/foo.json'), # 4 ^\n Location.from_path('/data/foo.yaml'), # 3 ^\n Location.from_env_keys(['FOO', 'BAR', 'BAZ']), # 2 ^\n Location.from_python('path.to.my.module') # 1 ^\n]\n```\n\nIn order to get this chaining, the `Config` must be initialized with the\nargument `chain=True`", "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/aventurella/confypy", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "confypy", "package_url": "https://pypi.org/project/confypy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/confypy/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/aventurella/confypy" }, "release_url": "https://pypi.org/project/confypy/0.2.5/", "requires_dist": null, "requires_python": null, "summary": "Configuration Loading Utility", "version": "0.2.5" }, "last_serial": 1683215, "releases": { "0.0.1": [], "0.1": [ { "comment_text": "", "digests": { "md5": "a8b60b1cc1783d593529da106f6c0ba1", "sha256": "c7226051c5f2b0fd4390498b704665a11e2c0e56578cc3da8c1936006cefadd1" }, "downloads": -1, "filename": "confypy-0.1.tar.gz", "has_sig": false, "md5_digest": "a8b60b1cc1783d593529da106f6c0ba1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5285, "upload_time": "2013-05-31T15:18:40", "url": "https://files.pythonhosted.org/packages/aa/ab/c828403255300f6e45319a47e27d54cbad15c7b70092f863d7b992e321f5/confypy-0.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "37f770370a39079718c66c397837c95b", "sha256": "b080fcfe79b570b374354e90ef7adddd86f4eb1003006b46e3c2f1de6c47f648" }, "downloads": -1, "filename": "confypy-0.2.0.tar.gz", "has_sig": false, "md5_digest": "37f770370a39079718c66c397837c95b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5770, "upload_time": "2013-07-01T18:59:50", "url": "https://files.pythonhosted.org/packages/da/ef/096febd7a18c46816041686ef86fe25b5cfa79cf6539979666a7b4cd8fab/confypy-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "0a632b87dea03bbabf506bcb49c97f63", "sha256": "fd8695b1c2492971cacb4c14d6c746e46371dd7c17b8cb44e180dd6f3fb13f68" }, "downloads": -1, "filename": "confypy-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0a632b87dea03bbabf506bcb49c97f63", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5781, "upload_time": "2013-10-15T13:23:38", "url": "https://files.pythonhosted.org/packages/3d/ae/3ee0234277e09060f884be0cdae01914c0358c2886020a4b3dc8327fdcb5/confypy-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "d9377cbbdca8fdeb51336304c6e8ccf3", "sha256": "87b753869d72d84838df2d05ae569ce8dfc3ff96b9f3ae754656ceb7a0eb0ee8" }, "downloads": -1, "filename": "confypy-0.2.2.tar.gz", "has_sig": false, "md5_digest": "d9377cbbdca8fdeb51336304c6e8ccf3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6007, "upload_time": "2013-10-21T18:03:07", "url": "https://files.pythonhosted.org/packages/35/ed/dd833c6855bba2a8c8d131a7ad71a3a7ee49e2afb8f03ac989bce612b0f1/confypy-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "built for Darwin-14.4.0", "digests": { "md5": "d4783bc6889819094171596427dc752b", "sha256": "6cf9cefabb73b3d387e79b7faaa42ad502c7809097982c57b0ddce507c8a52be" }, "downloads": -1, "filename": "confypy-0.2.3.macosx-10.10-x86_64.tar.gz", "has_sig": false, "md5_digest": "d4783bc6889819094171596427dc752b", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 9683, "upload_time": "2015-08-07T13:36:13", "url": "https://files.pythonhosted.org/packages/59/39/cb94d856153790b2108015ab6aec95f58b09f3be86c29c2a82d64d104a7f/confypy-0.2.3.macosx-10.10-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "1b135093b9585f7147e452207c195e53", "sha256": "dbd69a37cb5a4c0e425ebbfefe40c1f33b16bb9dea0661191a8fa3103e84fea2" }, "downloads": -1, "filename": "confypy-0.2.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1b135093b9585f7147e452207c195e53", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9079, "upload_time": "2015-08-07T13:36:16", "url": "https://files.pythonhosted.org/packages/1c/d7/eff3b5be0057891255cb822265183e672bc5e5a0867ee533e063a1264802/confypy-0.2.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ea31a7740b37390fe2be346f1a70c4cd", "sha256": "7b58119edcd90c5f13a35a2a2a8f00fc09333663175c85b3b2bfccbfd98ca339" }, "downloads": -1, "filename": "confypy-0.2.3.tar.gz", "has_sig": false, "md5_digest": "ea31a7740b37390fe2be346f1a70c4cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5937, "upload_time": "2015-08-07T13:36:09", "url": "https://files.pythonhosted.org/packages/25/f6/db7690c130dc53d5df8cf710a71ee747328287bd5827c43efb3e55c5e822/confypy-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "9a392d237317b9150f1ec3e0d0e257ea", "sha256": "d4cf0676a853e3f280e3445a4e8f91fe8dcbc122160b69fdc03788603edd8a01" }, "downloads": -1, "filename": "confypy-0.2.4-py2-none-any.whl", "has_sig": false, "md5_digest": "9a392d237317b9150f1ec3e0d0e257ea", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9088, "upload_time": "2015-08-18T23:40:17", "url": "https://files.pythonhosted.org/packages/f9/1c/a81058c66afea037295ad5a500106d57d4e8879292d33030fe319c6f5094/confypy-0.2.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b845f016c586b522df8800ecc19a3a5d", "sha256": "6eeeae214674bb2cf2e59e1ad17069e099d70e8404659f3ba8763b9953ae98b4" }, "downloads": -1, "filename": "confypy-0.2.4.tar.gz", "has_sig": false, "md5_digest": "b845f016c586b522df8800ecc19a3a5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5962, "upload_time": "2015-08-18T23:40:13", "url": "https://files.pythonhosted.org/packages/7d/ca/02433d767053b498e568565987e84088203565d3d05d3e75f69604ddca4c/confypy-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "756a9d0919268489dd65d13cb0214bb1", "sha256": "0cee2e035fae9bf3b88552e0b7f95512b79f848c98e57731b08a0688a19d9c72" }, "downloads": -1, "filename": "confypy-0.2.5-py2-none-any.whl", "has_sig": false, "md5_digest": "756a9d0919268489dd65d13cb0214bb1", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9100, "upload_time": "2015-08-18T23:50:43", "url": "https://files.pythonhosted.org/packages/51/9d/f19726db0c4ef83fa7def925181d46263351a91c5f0589a9fd1954575d0b/confypy-0.2.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "54b470f5945300fe0a8ea50c0b1464c7", "sha256": "98b93f84d83f73da462086897ca68f19ce4cf993d17a4fa24f7a5d25842e69e9" }, "downloads": -1, "filename": "confypy-0.2.5.tar.gz", "has_sig": false, "md5_digest": "54b470f5945300fe0a8ea50c0b1464c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5972, "upload_time": "2015-08-18T23:50:39", "url": "https://files.pythonhosted.org/packages/5c/90/c25557d7e172e0f3e7e89328580fe7ca246b15a800b988860e8a2c6f1999/confypy-0.2.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "756a9d0919268489dd65d13cb0214bb1", "sha256": "0cee2e035fae9bf3b88552e0b7f95512b79f848c98e57731b08a0688a19d9c72" }, "downloads": -1, "filename": "confypy-0.2.5-py2-none-any.whl", "has_sig": false, "md5_digest": "756a9d0919268489dd65d13cb0214bb1", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9100, "upload_time": "2015-08-18T23:50:43", "url": "https://files.pythonhosted.org/packages/51/9d/f19726db0c4ef83fa7def925181d46263351a91c5f0589a9fd1954575d0b/confypy-0.2.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "54b470f5945300fe0a8ea50c0b1464c7", "sha256": "98b93f84d83f73da462086897ca68f19ce4cf993d17a4fa24f7a5d25842e69e9" }, "downloads": -1, "filename": "confypy-0.2.5.tar.gz", "has_sig": false, "md5_digest": "54b470f5945300fe0a8ea50c0b1464c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5972, "upload_time": "2015-08-18T23:50:39", "url": "https://files.pythonhosted.org/packages/5c/90/c25557d7e172e0f3e7e89328580fe7ca246b15a800b988860e8a2c6f1999/confypy-0.2.5.tar.gz" } ] }