{ "info": { "author": "Carlos Perez", "author_email": "charlsagente@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "# python-settings\nThis module provides you easy access to your **config/settings** properties from all your python modules, it supports normal and lazy initialization for each property. It is based on \n [django.conf.settings](https://github.com/django/django/blob/stable/1.11.x/django/conf/__init__.py#L58').\n \n ## Installation\n From pip\n ```bash\n pip install python-settings\n```\n\nOr\n\nClone this repo and type\n```bash\npython setup.py install\n```\n\n ## Usage\n There are two ways to initialize this library\n * **Manual configuration**. Using python modules\n \n ```python\n # Avoid this way after installing python_settings\n from python_settings.tests.settings.base_settings import URL_CONFIG \n from python_settings.tests.settings import base_settings\n \n #Using this module\n from python_settings import settings\n settings.configure(base_settings) # configure() receives a python module\n assert settings.configured\n assert settings.URL_CONFIG == URL_CONFIG # now you can use settings in all your project\n \n ``` \n * Using an **environment variable**. You must have an environment variable called **SETTINGS_MODULE** pointing to your settings module in the format {module}.\n {settings}. With no .py extension.\n \n Example:\n ```bash\n export SETTINGS_MODULE='myproject.settings' \n ```\n or\n \n ```python\n import os\n os.environ[\"SETTINGS_MODULE\"] = 'myproject.settings' \n ```\n\nExample of the settings.py, it must contain variables in capital letter format:\n```python\n# settings.py\nfrom python_settings import LazySetting\n\nDATABASE_HOST = '10.0.0.1'\n\nDATABASE_NAME = 'DATABASENAME'\n\nLAZY_INITIALIZATION = LazySetting(HeavyInitializationClass, \"127.0.0.1:4222\") \n# LazySetting(Class, *args, **kwargs)\n```\n \nAnd from any module in your code, you should call your settings variables like this example:\n ```python\nfrom python_settings import settings \n\nprint(settings.DATABASE_HOST)\nprint(settings.DATABASE_NAME)\n# The initialization of the object will happen only once\nsettings.LAZY_INITIALIZATION.instantiated_object_fn() \n``` \n\n## Example for different environments\nYou can use as many settings files as you need for different environments.\nExample for development environment settings:\n```python\n# development_settings.py\nimport os\n\nfrom .base_settings import *\n\n\nTOKEN_API = os.environ.get(\"TOKEN_API\")\n\n\n```\n \n Example for testing environment\n ```python\n# testing_settings.py\nimport os\n\nfrom .settings import *\n\nDATABASE_HOST = '10.0.0.1'\n\nTOKEN_API = os.environ.get(\"TOKEN_API\")\n```\n\nAnd update your **SETTINGS_MODULE** variable \n ```bash\nexport SETTINGS_MODULE = 'myproject.settings.testing_settings'\n```\nor using the manual config\n\nTODO LIST: \n* Add compatibility with Python 2.7 in the LazyInitializer", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/charlsagente/python-settings-module", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-settings", "package_url": "https://pypi.org/project/python-settings/", "platform": "", "project_url": "https://pypi.org/project/python-settings/", "project_urls": { "Homepage": "https://github.com/charlsagente/python-settings-module" }, "release_url": "https://pypi.org/project/python-settings/0.2/", "requires_dist": null, "requires_python": "", "summary": "This module provides you easy access to your **config/settings** properties from all your python modules", "version": "0.2" }, "last_serial": 5210949, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "14d7a9c7f87e4afa89e08bde209c402c", "sha256": "e97384cd9d722829525240347d5e5709a64f0babbe3322bb92d6e66a76d1b61c" }, "downloads": -1, "filename": "python_settings-0.2.tar.gz", "has_sig": false, "md5_digest": "14d7a9c7f87e4afa89e08bde209c402c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3785, "upload_time": "2019-05-01T02:42:07", "url": "https://files.pythonhosted.org/packages/35/59/db7ed0a348fd12f5e6110f67593da1af400e501a12aa6e5de8544ec0e2ed/python_settings-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "14d7a9c7f87e4afa89e08bde209c402c", "sha256": "e97384cd9d722829525240347d5e5709a64f0babbe3322bb92d6e66a76d1b61c" }, "downloads": -1, "filename": "python_settings-0.2.tar.gz", "has_sig": false, "md5_digest": "14d7a9c7f87e4afa89e08bde209c402c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3785, "upload_time": "2019-05-01T02:42:07", "url": "https://files.pythonhosted.org/packages/35/59/db7ed0a348fd12f5e6110f67593da1af400e501a12aa6e5de8544ec0e2ed/python_settings-0.2.tar.gz" } ] }