{ "info": { "author": "Curtis Maloney", "author_email": "curtis@tinbrain.net", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "Confucius\n---------\n\n.. rubric:: A simpler, clearer approach to configuration.\n\n\nQuick Start\n===========\n\n.. code-block:: python\n :name: config.py\n\n from confucius import BaseConfig\n\n class Config(BaseConfig)\n HOST = '127.0.0.1'\n PORT : int = 8000\n\n DEBUG : bool = False\n\n.. code-block:: python\n :name: app.py\n\n from myapp import Server\n from config import Config\n\n\n server = Server(Config.HOST, Config.PORT)\n\n\n.. code-block:: sh\n\n $ python app.py\n - Starting server: 127.0.0.1:8000\n\n $ PORT=80 python app.py\n - Starting server: 127.0.0.1:80\n\n $ DEBUG=y python app.py\n - Starting debug server: 127.0.0.1:80\n\n\nTypes\n=====\n\nAny ``ANGRY_SNAKE_CASE`` attributes of a ``BaseConfig`` sub-class will be\nintercepted by the meta-class, and checked for in the environment using\n``os.getenv``.\n\nTheir type will be determined by their annotation in the class, or fall back to\n``str``.\n\nMethods will automatically behave like a ``property``, with access to ``self``.\n\nHandling of type casting can be overridden [as it is for bool] by adding it to\nthe ``__types__`` dict:\n\n.. code-block:: python\n\n class Config(BaseConfig):\n __types__ = {\n json: lambda v: json.loads(v) if isinstance(v, str) else v,\n }\n \n LOGGING : json = {'version': 1 ...}\n\nAll types defined on parent ``Config`` classes will be merged with this dict.\n\nInheritance\n===========\n\nClasses, as usual, inherit from their parents. If the type of an attribute is\nchanged, it will raise an ``AssertionError``.\n\nMethods\n=======\n\nMethod in all-caps will be invoked, and can access ``self`` as usual:\n\n.. code-block:: python\n\n class Config(BaseConfig):\n DB_ENGINE = 'postgresql'\n DB_HOST = 'localhost'\n DB_PORT : int = 5432\n DB_USER = 'test_user'\n DB_PASS = 'secret'\n DB_NAME = 'test-db'\n\n def CONNECTION_STRING(self):\n return f'{self.DB_ENGINE}://{self.DB_USER}:{self.DB_PASS}@{self.DB_HOST}/{self.DB_NAME}'\n\n\nUsing in Django\n---------------\n\n\nIn your ``settings.py``, put your settings class (or classes), then use the following code to select one to use:\n\n.. code-block:: python\n\n import os\n MODE = os.getenv('DJANGO_MODE', 'Local')\n globals().update(globals()[f'{ MODE.title() }Settings'].as_dict())\n\n\nWith Python 3.7\n===============\n\nIn Python 3.7, a new feature was added which allowed you to define\n`__getattr__` for a module (See `PEP 562`\n).\n\nThe `BaseConfig` metaclass provides a `module_getattr_factory` factory method\nto provide a `__getattr__` that will look up the `Config` object.\n\n\n.. code-block:: python\n\n from confucius import BaseConfig\n\n class Config(BaseConfig):\n DB_HOST = 'localhost'\n DB_PORT = 5432\n\n __getattr__ = Config.module_getattr_factory()\n\n\nAfter importing this module, attempts to access attributes will resolve\nnormally and, if they're not found, call `__getattr__`, just like on an object.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/funkybob/confucius", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "confucius", "package_url": "https://pypi.org/project/confucius/", "platform": "", "project_url": "https://pypi.org/project/confucius/", "project_urls": { "Homepage": "http://github.com/funkybob/confucius" }, "release_url": "https://pypi.org/project/confucius/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "An easy way to provide environ backed config in your projects.", "version": "1.0.3" }, "last_serial": 4956825, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "63aea9ee01968c4ab1395220271393b8", "sha256": "078b07cd7869faca708b832d4617a4890dae3cb19f3fe5d76ee128ce95a386c0" }, "downloads": -1, "filename": "confucius-1.0.0.tar.gz", "has_sig": false, "md5_digest": "63aea9ee01968c4ab1395220271393b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1891, "upload_time": "2019-01-08T03:45:24", "url": "https://files.pythonhosted.org/packages/33/ec/0569f05de96c2016508597594c4ceede456223751f519337947b1f6a593c/confucius-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "0a46c5e5d11f2a941c4ebc9c05607d23", "sha256": "a1fd7c694492991ec58bfd553fc8324e58d5149de4e9c56fcfd852e9572dd9bd" }, "downloads": -1, "filename": "confucius-1.0.1.tar.gz", "has_sig": false, "md5_digest": "0a46c5e5d11f2a941c4ebc9c05607d23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2554, "upload_time": "2019-01-08T21:59:55", "url": "https://files.pythonhosted.org/packages/0b/d4/7117222260c8371dac2223930396834b12933b5b03630b92075e2dcda908/confucius-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "c55be3a3094cbb918bf04b38c16acec5", "sha256": "1348f590f5b18c042258b18ebf5b78f23d140a02fd37633fdb1ef8a6e166a9ee" }, "downloads": -1, "filename": "confucius-1.0.2.tar.gz", "has_sig": false, "md5_digest": "c55be3a3094cbb918bf04b38c16acec5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3450, "upload_time": "2019-03-18T22:41:36", "url": "https://files.pythonhosted.org/packages/07/9a/1c67d74c8954dd8958424275263e19318ba9b0c7738b3493635f81d2d658/confucius-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "c24e32db0b31e0ce9acc31f132e9af8d", "sha256": "eb2f920513a2a1876b7140c6e0d675b28606c517b42687725dd54a39f331d7db" }, "downloads": -1, "filename": "confucius-1.0.3.tar.gz", "has_sig": false, "md5_digest": "c24e32db0b31e0ce9acc31f132e9af8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3441, "upload_time": "2019-03-19T03:26:34", "url": "https://files.pythonhosted.org/packages/14/47/aa206dfe70a7f7f6d962cd504e6b67046f37df0b2b636b0d756acb3e735e/confucius-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c24e32db0b31e0ce9acc31f132e9af8d", "sha256": "eb2f920513a2a1876b7140c6e0d675b28606c517b42687725dd54a39f331d7db" }, "downloads": -1, "filename": "confucius-1.0.3.tar.gz", "has_sig": false, "md5_digest": "c24e32db0b31e0ce9acc31f132e9af8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3441, "upload_time": "2019-03-19T03:26:34", "url": "https://files.pythonhosted.org/packages/14/47/aa206dfe70a7f7f6d962cd504e6b67046f37df0b2b636b0d756acb3e735e/confucius-1.0.3.tar.gz" } ] }